home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume23 / trn / part13 < prev    next >
Encoding:
Text File  |  1991-08-22  |  64.0 KB  |  2,551 lines

  1. This is a new archive version of TRN at patchlevel 3.
  2. The original posting took up Volume23, issues 60 to 73, with
  3. various problems.  These files replace those issues.
  4.  
  5. #! /bin/sh
  6. # This is a shell archive.  Remove anything before this line, then feed it
  7. # into a shell via "sh file" or similar.  To overwrite existing files,
  8. # type "sh file -c".
  9. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  10. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  11. # Contents:  NEW Pnews.1 Rnmail.1 addng.c artio.c backpage.c
  12. #   getactive.c makedepend.SH mbox.saver.SH mthreads.h ndir.c ndir.h
  13. #   newsetup.1 newsetup.SH newsgroups.1 newsgroups.SH ngsrch.c only.c
  14. #   rthreads.h threads.c threads.h
  15. # Wrapped by rsalz@litchi.bbn.com on Fri Aug 23 16:39:03 1991
  16. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  17. echo If this archive is complete, you will see the following message:
  18. echo '          "shar: End of archive 13 (of 14)."'
  19. if test -f 'NEW' -a "${1}" != "-c" ; then 
  20.   echo shar: Will not clobber existing file \"'NEW'\"
  21. else
  22.   echo shar: Extracting \"'NEW'\" \(2877 characters\)
  23.   sed "s/^X//" >'NEW' <<'END_OF_FILE'
  24. X            NEW FEATURES OF TRN 1.0 vs RN 4.3
  25. X
  26. XNew commands (article level)
  27. X    t        display a map of the thread's article tree.
  28. X    [, ], {, }    move around in the article tree
  29. X    J        junk an entire thread of disucussion regardless of
  30. X            subject changes.
  31. X    T        put the entire thread of discussion in the KILL file
  32. X            (as opposed to the current subject).
  33. X    <, >        move between threads of discussion
  34. X    U        mark some articles as unread again (choose from
  35. X            the current thread, subthread, selected threads, or
  36. X            all articles).
  37. X    e        extract a shar or uuencoded file.
  38. X    :        execute a command on all the selected threads/articles
  39. X
  40. XNew commands (newsgroup level)
  41. X    +        enter a newsgroup through the thread selector.
  42. X    U        enter a newsgroup through the "set unread" prompt.
  43. X
  44. XNew commands (thread selector)
  45. X    [...lots...]    use the thread selector to quickly browse the subjects
  46. X            and/or authors of articles and select only the ones
  47. X            that you want to read.  You can read each one as
  48. X            soon as you select it, or select them all at once.
  49. X            Use the 'h' command to see a command summary, or read
  50. X            the man page for more details.
  51. X
  52. XNew header display:    we display a subset of the thread's article tree in
  53. X            each header.
  54. X
  55. XNew display ordering:    the articles appear in their reply order.
  56. X
  57. XNew switches (default may be on, use +x/+X to turn them off)
  58. X    -x        turn on threaded extensions.
  59. X    -X        use thread selector to enter a group.
  60. X
  61. XNew magic (use +H to turn them off)
  62. X    -Hfrom        displays only the commented portion of the user name.
  63. X    -Hdate        displays the date in local time.
  64. X
  65. XNew environment variables
  66. X    EXSAVER        shell command that starts an extraction.
  67. X    SELECTCHARS    the character set to use to select threads
  68. X            (default:  abcdefgijlorstuvwxz1234567890).
  69. X    UNSHAR        the unshar program to use (default /bin/sh).
  70. X    REPLYTO        the value to use for the "Reply-To:" header, if
  71. X            needed.
  72. X
  73. XNew mode
  74. X    %m=t        when in the thread selector
  75. X
  76. XNew % interpolations
  77. X    %#        keeps an incremental count during a multi-file save,
  78. X            extract, etc.  ":s part.%#"
  79. X    %e        the last command executed to extract an article.
  80. X    %E        The number of extra (unselected) articles, not
  81. X            counting the current article (if selected).
  82. X    %U        same as before (number of unread articles, not counting
  83. X            the current one) but if selections are on, only counts
  84. X            selected articles.
  85. X    %Z        The number of selected threads.
  86. X
  87. XMacros and Keymaps
  88. X    When defining macros, make sure you don't define something that
  89. X    will conflict with the selection characters in the thread selector.
  90. X    An easy way is to exclude the thread selector with a mode test:
  91. X
  92. X        f    %(%m=t?f:|mail smith\n)
  93. X
  94. X    Also, if you want to use one of the selection characters as a
  95. X    command in the thread selector, be sure to exclude it from the
  96. X    list of selection characters in SELECTCHARS (you can define this
  97. X    with -ESELECTCHARS=abc123 in your .rninit file).
  98. X
  99. XMiscellaneous
  100. X    ...and much, much more! (including various bug fixes!)
  101. END_OF_FILE
  102.   if test 2877 -ne `wc -c <'NEW'`; then
  103.     echo shar: \"'NEW'\" unpacked with wrong size!
  104.   fi
  105.   # end of 'NEW'
  106. fi
  107. if test -f 'Pnews.1' -a "${1}" != "-c" ; then 
  108.   echo shar: Will not clobber existing file \"'Pnews.1'\"
  109. else
  110.   echo shar: Extracting \"'Pnews.1'\" \(3130 characters\)
  111.   sed "s/^X//" >'Pnews.1' <<'END_OF_FILE'
  112. X''' $Header: Pnews.1,v 4.3.3.1 90/07/21 19:57:23 davison Trn $
  113. X''' 
  114. X''' $Log:    Pnews.1,v $
  115. X''' Revision 4.3.3.1  90/07/21  19:57:23  davison
  116. X''' Initial Trn Release
  117. X''' 
  118. X''' Revision 4.3.1.2  85/08/01  14:22:48  lwall
  119. X''' Added AUTHORCOPY.
  120. X''' 
  121. X''' Revision 4.3.1.1  85/05/10  11:30:30  lwall
  122. X''' Branch for patches.
  123. X''' 
  124. X''' Revision 4.3  85/05/01  11:33:50  lwall
  125. X''' Baseline for release with 4.3bsd.
  126. X''' 
  127. X.de Sh
  128. X.br
  129. X.ne 5
  130. X.PP
  131. X\fB\\$1\fR
  132. X.PP
  133. X..
  134. X.de Sp
  135. X.if t .sp .5v
  136. X.if n .sp
  137. X..
  138. X'''
  139. X'''     Set up \*(-- to give an unbreakable dash;
  140. X'''     string Tr holds user defined translation string.
  141. X'''     Bell System Logo is used as a dummy character.
  142. X'''
  143. X.ie n \{\
  144. X.tr \(bs-\*(Tr
  145. X.ds -- \(bs-
  146. X.if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch
  147. X.if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch
  148. X.ds L" ""
  149. X.ds R" ""
  150. X.ds L' '
  151. X.ds R' '
  152. X'br\}
  153. X.el\{\
  154. X.ds -- \(em\|
  155. X.tr \*(Tr
  156. X.ds L" ``
  157. X.ds R" ''
  158. X.ds L' `
  159. X.ds R' '
  160. X'br\}
  161. X.TH PNEWS 1 LOCAL
  162. X.SH NAME
  163. XPnews - a program for posting news articles
  164. X.SH SYNOPSIS
  165. X.B Pnews newsgroup title
  166. X.br
  167. X  or
  168. X.br
  169. X.B Pnews -h headerfile [oldarticle]
  170. X.br
  171. X  or
  172. X.br
  173. X.B Pnews
  174. X.SH DESCRIPTION
  175. XPnews is a friendly interface for posting news articles.
  176. XIt will ask several questions, then allow you to enter your article,
  177. Xand then post it using the inews(1) program.
  178. XIf you type h and a carriage return at any point,
  179. X.I Pnews
  180. Xwill tell you what it wants to know.
  181. X.PP
  182. XThe -h form is used when invoked from
  183. X.IR rn .
  184. XIf your editor can edit multiple files, and you want the article to which
  185. Xyou are replying to show up as an alternate file, define the environment
  186. Xvariable NEWSPOSTER as \*(L"Pnews -h %h %A\*(R".
  187. XYou can also modify the the NEWSHEADER environment variable to change the
  188. Xheader file that
  189. X.I rn
  190. Xpasses to Pnews.
  191. X.SH ENVIRONMENT
  192. X.IP AUTHORCOPY 8
  193. XIf defined, contains the name of a file to which the finished article will
  194. Xbe appended.
  195. X.Sp
  196. XDefault: article not saved
  197. X.IP DOTDIR 8
  198. XWhere to find your dot files, if they aren't in your home directory.
  199. XThis is primarily for accounts which are shared by more than one person.
  200. X.Sp
  201. XDefault: $HOME
  202. X.IP EDITOR 8
  203. XThe editor you want to use, if VISUAL is undefined.
  204. X.Sp
  205. XDefault: whatever your news administrator installed, usually vi.
  206. X.IP HOME 8
  207. XYour home directory.
  208. X.Sp
  209. XDefault: $LOGDIR
  210. X.IP LOGDIR 8
  211. XYour home directory if HOME is undefined.
  212. X.IP LOGNAME 8
  213. XYour login name, if USER is undefined.
  214. X.Sp
  215. XDefault: value of \*(L"whoami\*(R".
  216. X.IP NAME 8
  217. XYour full name.
  218. X.Sp
  219. XDefault: name from /etc/passwd, or ~/.fullname.
  220. X.IP ORGANIZATION 8
  221. XEither the name of your organization, or the name of a file containing the
  222. Xname of your organization.
  223. X.Sp
  224. XDefault: whatever your news administrator chose.
  225. X.IP REPLYTO 8
  226. XThe contents of a \*(L"Reply-To:\*(R" header line to insert into your message.
  227. X.Sp
  228. XDefault: header line not inserted.
  229. X.IP USER 8
  230. XYour login name.
  231. X.Sp
  232. XDefault: $LOGNAME
  233. X.IP VISUAL 8
  234. XThe editor you want to use.
  235. X.Sp
  236. XDefault: $EDITOR
  237. X.SH FILES
  238. X$DOTDIR/.article
  239. X.br
  240. X~/dead.article
  241. X.SH SEE ALSO
  242. Xrn(1), Rnmail(1), inews(1)
  243. X.SH DIAGNOSTICS
  244. X.SH BUGS
  245. XNot the speediest program in the world, but maybe that's a blessing to the
  246. Xnet.
  247. END_OF_FILE
  248.   if test 3130 -ne `wc -c <'Pnews.1'`; then
  249.     echo shar: \"'Pnews.1'\" unpacked with wrong size!
  250.   fi
  251.   # end of 'Pnews.1'
  252. fi
  253. if test -f 'Rnmail.1' -a "${1}" != "-c" ; then 
  254.   echo shar: Will not clobber existing file \"'Rnmail.1'\"
  255. else
  256.   echo shar: Extracting \"'Rnmail.1'\" \(3038 characters\)
  257.   sed "s/^X//" >'Rnmail.1' <<'END_OF_FILE'
  258. X''' $Header: Rnmail.1,v 4.3.3.1 90/07/21 19:57:27 davison Trn $
  259. X''' 
  260. X''' $Log:    Rnmail.1,v $
  261. X''' Revision 4.3.3.1  90/07/21  19:57:27  davison
  262. X''' Initial Trn Release
  263. X''' 
  264. X''' Revision 4.3.1.2  85/08/01  14:22:08  lwall
  265. X''' Added MAILRECORD, DOTDIR.
  266. X''' 
  267. X''' Revision 4.3.1.1  85/05/10  11:30:44  lwall
  268. X''' Branch for patches.
  269. X''' 
  270. X''' Revision 4.3  85/05/01  11:34:28  lwall
  271. X''' Baseline for release with 4.3bsd.
  272. X''' 
  273. X.de Sh
  274. X.br
  275. X.ne 5
  276. X.PP
  277. X\fB\\$1\fR
  278. X.PP
  279. X..
  280. X.de Sp
  281. X.if t .sp .5v
  282. X.if n .sp
  283. X..
  284. X'''
  285. X'''     Set up \*(-- to give an unbreakable dash;
  286. X'''     string Tr holds user defined translation string.
  287. X'''     Bell System Logo is used as a dummy character.
  288. X'''
  289. X.ie n \{\
  290. X.tr \(bs-\*(Tr
  291. X.ds -- \(bs-
  292. X.if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch
  293. X.if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch
  294. X.ds L" ""
  295. X.ds R" ""
  296. X.ds L' '
  297. X.ds R' '
  298. X'br\}
  299. X.el\{\
  300. X.ds -- \(em\|
  301. X.tr \*(Tr
  302. X.ds L" ``
  303. X.ds R" ''
  304. X.ds L' `
  305. X.ds R' '
  306. X'br\}
  307. X.TH RNMAIL 1 LOCAL
  308. X.SH NAME
  309. XRnmail - a program for replying via mail
  310. X.SH SYNOPSIS
  311. X.B Rnmail destination_list
  312. X.br
  313. X  or
  314. X.br
  315. X.B Rnmail -h headerfile [oldarticle]
  316. X.br
  317. X  or
  318. X.br
  319. X.B Rnmail
  320. X.SH DESCRIPTION
  321. XRnmail is a friendly interface for mailing replies to news articles.
  322. XIt will ask several questions, then allow you to enter your letter,
  323. Xand then mail it off.
  324. XIf you type h and a carriage return at any point,
  325. X.I Rnmail
  326. Xwill tell you what it wants to know.
  327. X.PP
  328. XThe -h form is used when invoked from
  329. X.IR rn .
  330. XIf your editor can edit multiple files, and you want the article to which
  331. Xyou are replying to show up as an alternate file, define the environment
  332. Xvariable MAILPOSTER as \*(L"Rnmail -h %h %A\*(R".
  333. XYou can also modify the the MAILHEADER environment variable to change the
  334. Xheader file that
  335. X.I rn
  336. Xpasses to Rnmail.
  337. X.SH ENVIRONMENT
  338. X.IP DOTDIR 8
  339. XIf defined, specifies a place other than your home directory where 'dot' files
  340. Xmay be stored.
  341. XThis is primarily for accounts which are shared by more than one person.
  342. X.Sp
  343. XDefault: $HOME
  344. X.IP EDITOR 8
  345. XThe editor you want to use, if VISUAL is undefined.
  346. X.Sp
  347. XDefault: whatever your news administrator installed, usually vi.
  348. X.IP HOME 8
  349. XYour home directory.
  350. X.Sp
  351. XDefault: $LOGDIR
  352. X.IP LOGDIR 8
  353. XYour home directory if HOME is undefined.
  354. X.IP LOGNAME 8
  355. XYour login name, if USER is undefined.
  356. X.Sp
  357. XDefault: value of \*(L"whoami\*(R".
  358. X.IP MAILRECORD 8
  359. XIf defined, contains the name of a file to which the finished message will
  360. Xbe appended.
  361. X.Sp
  362. XDefault: message not saved
  363. X.IP ORGANIZATION 8
  364. XEither the name of your organization, or the name of a file containing the
  365. Xname of your organization.
  366. X.Sp
  367. XDefault: whatever your news administrator chose.
  368. X.IP REPLYTO 8
  369. XThe contents of a \*(L"Reply-To:\*(R" header line to insert into your message.
  370. X.Sp
  371. XDefault: header line not inserted.
  372. X.IP USER 8
  373. XYour login name.
  374. X.Sp
  375. XDefault: $LOGNAME
  376. X.IP VISUAL 8
  377. XThe editor you want to use.
  378. X.Sp
  379. XDefault: $EDITOR
  380. X.SH FILES
  381. X$DOTDIR/.letter
  382. X.br
  383. X~/dead.letter
  384. X.SH SEE ALSO
  385. Xrn(1), Pnews(1), mail(1)
  386. X.SH DIAGNOSTICS
  387. X.SH BUGS
  388. XUses /bin/mail in the absence of sendmail.
  389. END_OF_FILE
  390.   if test 3038 -ne `wc -c <'Rnmail.1'`; then
  391.     echo shar: \"'Rnmail.1'\" unpacked with wrong size!
  392.   fi
  393.   # end of 'Rnmail.1'
  394. fi
  395. if test -f 'addng.c' -a "${1}" != "-c" ; then 
  396.   echo shar: Will not clobber existing file \"'addng.c'\"
  397. else
  398.   echo shar: Extracting \"'addng.c'\" \(4695 characters\)
  399.   sed "s/^X//" >'addng.c' <<'END_OF_FILE'
  400. X/* $Header: addng.c,v 4.3.3.3 91/01/16 02:20:43 davison Trn $
  401. X *
  402. X * $Log:    addng.c,v $
  403. X * Revision 4.3.3.3  91/01/16  02:20:43  davison
  404. X * Integrated rn patches 48-54.
  405. X * 
  406. X * Revision 4.3.3.2  90/08/20  16:27:06  davison
  407. X * Allow breaking out of ng adding.  Don't add 'X'ed groups.
  408. X * 
  409. X * Revision 4.3.3.1  90/06/20  22:35:43  davison
  410. X * Initial Trn Release
  411. X * 
  412. X * Revision 4.3.2.6  90/11/22  16:06:35  sob
  413. X * Changes to make pickly C preprocessors happier.
  414. X * 
  415. X * Revision 4.3.2.5  90/09/04  23:29:51  sob
  416. X * Added fix for bithof() from bug report by kwthomas@nsslsun.gcn.uoknor.edu
  417. X * 
  418. X * Revision 4.3.2.4  90/03/17  17:11:36  sob
  419. X * Added support for CNEWS active file flags.
  420. X * 
  421. X * Revision 4.3.2.3  89/11/08  02:33:28  sob
  422. X * Added include for server.h
  423. X * 
  424. X * Revision 4.3.2.2  89/11/08  01:23:49  sob
  425. X * Added GROUP check when SERVER defined.
  426. X * 
  427. X * Revision 4.3.2.1  89/11/06  00:34:11  sob
  428. X * Added RRN support from NNTP 1.5
  429. X * 
  430. X * Revision 4.3.1.2  85/05/29  09:06:24  lwall
  431. X * New newsgroups without spool directories incorrectly classified as "ancient".
  432. X * 
  433. X * Revision 4.3.1.1  85/05/10  11:30:50  lwall
  434. X * Branch for patches.
  435. X * 
  436. X * Revision 4.3  85/05/01  11:34:41  lwall
  437. X * Baseline for release with 4.3bsd.
  438. X * 
  439. X */
  440. X
  441. X#include "EXTERN.h"
  442. X#include "common.h"
  443. X#include "rn.h"
  444. X#include "ngdata.h"
  445. X#include "last.h"
  446. X#include "util.h"
  447. X#include "intrp.h"
  448. X#include "only.h"
  449. X#include "rcstuff.h"
  450. X#ifdef SERVER
  451. X#include "server.h"
  452. X#endif
  453. X#include "final.h"
  454. X#include "INTERN.h"
  455. X#include "addng.h"
  456. X
  457. Xvoid
  458. Xaddng_init()
  459. X{
  460. X    ;
  461. X}
  462. X
  463. X#ifdef FINDNEWNG
  464. X/* generate a list of new newsgroups from active file */
  465. X
  466. Xbool
  467. Xnewlist(munged,checkinlist)
  468. Xbool munged;                /* are we scanning the whole file? */
  469. Xbool checkinlist;
  470. X{
  471. X    char *tmpname;
  472. X    register char *s, *status;
  473. X    long birthof();
  474. X
  475. X    tmpname = savestr(filexp(RNEWNAME));
  476. X    tmpfp = fopen(tmpname,"w");
  477. X    if (tmpfp == Nullfp) {
  478. X    printf(cantcreate,tmpname) FLUSH;
  479. X    return FALSE;
  480. X    }
  481. X    while (fgets(buf,LBUFLEN,actfp) != Nullch) {
  482. X    /* Check if they want to break out of the new newsgroups search */
  483. X    if (int_count) {
  484. X        int_count = 0;
  485. X        fclose(tmpfp);
  486. X        UNLINK(tmpname);
  487. X        free(tmpname);
  488. X        return FALSE;
  489. X    }
  490. X    if (s = index(buf,' ')) {
  491. X        status=s;
  492. X        while (isdigit(*status) || isspace(*status)) status++;
  493. X        *s++ = '\0';
  494. X#ifdef USETHREADS
  495. X        if (strnEQ(buf,"to.",3) || *status == 'x' || *status == 'X'
  496. X                    || *status == '=')
  497. X#else
  498. X        if (strnEQ(buf,"to.",3) || *status == 'x' || *status == '=')
  499. X#endif
  500. X            /* since = groups are refiling to another group, just
  501. X           ignore their existence */
  502. X        continue;
  503. X        if (find_ng(buf) == nextrcline &&
  504. X            (checkinlist ?
  505. X            (inlist(buf)) :
  506. X            (birthof(buf,(ART_NUM)atol(s)) > lasttime)
  507. X            )
  508. X        ) {
  509. X                    /* if not in .newsrc and younger */
  510. X                    /* than the last time we checked */
  511. X        fprintf(tmpfp,"%s\n",buf);
  512. X                    /* then remember said newsgroup */
  513. X        }
  514. X#ifdef FASTNEW
  515. X        else {            /* not really a new group */
  516. X        if (!munged) {        /* did we assume not munged? */
  517. X            fclose(tmpfp);    /* then go back, knowing that */
  518. X            UNLINK(tmpname);
  519. X            free(tmpname);
  520. X            return TRUE;    /* active file was indeed munged */
  521. X        }
  522. X        }
  523. X#endif
  524. X    }
  525. X#ifdef DEBUGGING
  526. X    else
  527. X        printf("Bad active record: %s\n",buf) FLUSH;
  528. X#endif
  529. X    }
  530. X
  531. X    /* we have successfully generated the list */
  532. X
  533. X    fclose(tmpfp);
  534. X    tmpfp = fopen(tmpname,"r");
  535. X    UNLINK(tmpname);            /* be nice to the world */
  536. X    if (tmpfp == Nullfp) {
  537. X    printf(cantopen,tmpname) FLUSH;
  538. X    return FALSE;
  539. X    }
  540. X    while (fgets(buf,LBUFLEN,tmpfp) != Nullch) {
  541. X    buf[strlen(buf)-1] = '\0';
  542. X    get_ng(buf,TRUE);        /* add newsgroup, maybe */
  543. X    }
  544. X    fclose(tmpfp);            /* be nice to ourselves */
  545. X    free(tmpname);
  546. X    return FALSE;            /* do not call us again */
  547. X}
  548. X
  549. X/* return creation time of newsgroup */
  550. X
  551. Xlong
  552. Xbirthof(ngnam,ngsize)
  553. Xchar *ngnam;
  554. XART_NUM ngsize;
  555. X{
  556. X    char tst[128];
  557. X    long time();
  558. X#ifdef SERVER
  559. X    int x,tot,min,max;
  560. X    sprintf(tst,"GROUP %s",ngnam);
  561. X    put_server(tst);
  562. X    (void) get_server(tst, sizeof(tst));
  563. X    if (*tst != CHAR_OK) return(0); /* not a real group */
  564. X    (void) sscanf(tst,"%d%d%d%d",&x,&tot,&min,&max);
  565. X    if (tot > 0) return(time(Null(long *)));
  566. X    else return(0);
  567. X#else /* not SERVER */
  568. X
  569. X    sprintf(tst, ngsize ? "%s/%s/1" : "%s/%s" ,spool,getngdir(ngnam));
  570. X    if (stat(tst,&filestat) < 0)
  571. X    return (ngsize ? 0L : time(Null(long *)));
  572. X    /* not there, assume something good */
  573. X    else
  574. X    return filestat.st_mtime;
  575. X
  576. X#endif
  577. X}
  578. X
  579. Xbool
  580. Xscanactive()
  581. X{
  582. X    NG_NUM oldnext = nextrcline;    /* remember # lines in newsrc */
  583. X
  584. X    fseek(actfp,0L,0);
  585. X    newlist(TRUE,TRUE);
  586. X    if (nextrcline != oldnext) {    /* did we add any new groups? */
  587. X    return TRUE;
  588. X    }
  589. X    return FALSE;
  590. X}
  591. X
  592. X#endif
  593. X
  594. END_OF_FILE
  595.   if test 4695 -ne `wc -c <'addng.c'`; then
  596.     echo shar: \"'addng.c'\" unpacked with wrong size!
  597.   fi
  598.   # end of 'addng.c'
  599. fi
  600. if test -f 'artio.c' -a "${1}" != "-c" ; then 
  601.   echo shar: Will not clobber existing file \"'artio.c'\"
  602. else
  603.   echo shar: Extracting \"'artio.c'\" \(4969 characters\)
  604.   sed "s/^X//" >'artio.c' <<'END_OF_FILE'
  605. X/* $Header: artio.c,v 4.3.3.3 91/01/16 02:20:48 davison Trn $
  606. X *
  607. X * $Log:    artio.c,v $
  608. X * Revision 4.3.3.3  91/01/16  02:20:48  davison
  609. X * Integrated rn patches 48-54.
  610. X * 
  611. X * Revision 4.3.3.2  90/08/20  16:25:50  davison
  612. X * Fixed bug in artopen ==> nntpopen interaction.
  613. X * 
  614. X * Revision 4.3.3.1  90/07/21  20:11:03  davison
  615. X * Initial Trn Release
  616. X * 
  617. X * Revision 4.3.2.6  90/11/22  16:06:57  sob
  618. X * Changes to make pickly C preprocessors happier.
  619. X * 
  620. X * Revision 4.3.2.5  90/03/22  23:04:04  sob
  621. X * Fixes provided by Wayne Davison <drivax!davison>
  622. X * 
  623. X * Revision 4.3.2.4  89/11/27  01:29:57  sob
  624. X * Altered NNTP code per ideas suggested by Bela Lubkin
  625. X * <filbo@gorn.santa-cruz.ca.us>
  626. X * 
  627. X * Revision 4.3.2.3  89/11/26  22:55:31  sob
  628. X * Add nntpopen() and nntpclose() routines to cut down on size of rrn
  629. X * 
  630. X * Revision 4.3.2.2  89/11/08  01:17:12  sob
  631. X * Added changes to insure that this will compile for RN or RRN with no
  632. X * changes to the source code.
  633. X * 
  634. X * Revision 4.3.2.1  89/11/06  00:07:25  sob
  635. X * Added RRN support from NNTP 1.5
  636. X * 
  637. X * Revision 4.3  85/05/01  11:35:39  lwall
  638. X * Baseline for release with 4.3bsd.
  639. X * 
  640. X */
  641. X
  642. X#include "EXTERN.h"
  643. X#include "common.h"
  644. X#ifdef SERVER
  645. X#include "server.h"
  646. X#endif
  647. X#include "INTERN.h"
  648. X#include "artio.h"
  649. X
  650. Xvoid
  651. Xartio_init()
  652. X{
  653. X    ;
  654. X}
  655. X
  656. X/* open an article, unless it's already open */
  657. X
  658. XFILE *
  659. Xartopen(artnum)
  660. XART_NUM artnum;
  661. X{
  662. X#ifdef SERVER
  663. X    return nntpopen(artnum,GET_ARTICLE);
  664. X#else
  665. X    char artname[32];            /* filename of current article */
  666. X
  667. X    if (artnum < 1)
  668. X    return Nullfp;
  669. X    if (openart == artnum) {        /* this article is already open? */
  670. X    fseek(artfp,0L,0);        /* just get to the beginning */
  671. X    return artfp;            /* and say we succeeded */
  672. X    }
  673. X    if (artfp != Nullfp) {        /* it was somebody else? */
  674. X    fclose(artfp);            /* put them out of their misery */
  675. X    openart = 0;            /* and remember them no more */
  676. X    }
  677. X    sprintf(artname,"%ld",(long)artnum);
  678. X                    /* produce the name of the article */
  679. X    if (artfp = fopen(artname,"r"))    /* if we can open it */
  680. X    openart = artnum;        /* remember what we did here */
  681. X#ifdef LINKART
  682. X    {
  683. X    char tmpbuf[256];
  684. X    char *s;
  685. X
  686. X    if (fstat(fileno(artfp),&filestat))
  687. X        return artfp;
  688. X    if (filestat.st_size < (sizeof tmpbuf)) {
  689. X        fgets(tmpbuf,(sizeof tmpbuf),artfp);
  690. X        if (*tmpbuf == '/') {    /* is a "link" to another article */
  691. X        fclose(artfp);
  692. X        if (s=index(tmpbuf,'\n'))
  693. X            *s = '\0';
  694. X        if (!(artfp = fopen(tmpbuf,"r")))
  695. X            openart = 0;
  696. X        else {
  697. X            if (*linkartname)
  698. X            free(linkartname);
  699. X            linkartname = savestr(tmpbuf);
  700. X        }
  701. X        }
  702. X        else
  703. X        fseek(artfp,0L,0);        /* get back to the beginning */
  704. X    }
  705. X    }
  706. X#endif
  707. X    return artfp;            /* and return either fp or NULL */
  708. X#endif /* SERVER */
  709. X}
  710. X
  711. X#ifdef SERVER
  712. Xstatic long our_pid=0;
  713. X
  714. XFILE *
  715. Xnntpopen(artnum,function)
  716. XART_NUM artnum;
  717. XART_PART function;
  718. X{
  719. X    char ser_line[256];
  720. X    char artname[32];            /* filename of current article */
  721. X    if (our_pid == 0)
  722. X    our_pid = getpid();
  723. X    if (artnum < 1)
  724. X    return Nullfp;
  725. X    if ((openart == artnum) && (openpart >= function))
  726. X    {                    /* this article is already open? */
  727. X    fseek(artfp,0L,0);        /* just get to the beginning */
  728. X    return artfp;            /* and say we succeeded */
  729. X    }
  730. X    if (artfp != Nullfp) {        /* it was somebody else? */
  731. X    fclose(artfp);            /* put them out of their misery */
  732. X    nntpclose();
  733. X    openart = 0;            /* and remember them no more */
  734. X    }
  735. X    sprintf(artname,"/tmp/rrn%ld.%ld", (long) artnum, our_pid);
  736. X    artfp = fopen(artname, "w+");    /* create the temporary article */
  737. X    if (artfp == Nullfp) {
  738. X    UNLINK(artname);
  739. X    return Nullfp;
  740. X    }
  741. X    switch (function){
  742. X        case GET_STATUS:
  743. X        function = GET_HEADER;    /* fall through */
  744. X        case GET_HEADER:
  745. X        sprintf(ser_line, "HEAD %ld", (long)artnum);
  746. X        break;
  747. X        case GET_ARTICLE:
  748. X        sprintf(ser_line, "ARTICLE %ld", (long)artnum);
  749. X        break;
  750. X    }        
  751. X    put_server(ser_line);        /* ask the server for the article */
  752. X    if (get_server(ser_line, sizeof(ser_line)) < 0) {
  753. X    fprintf(stderr, "rrn: Unexpected close of server socket.\n");
  754. X    finalize(1);
  755. X    }
  756. X    if (*ser_line != CHAR_OK) {        /* and get it's reaction */
  757. X    fclose(artfp);
  758. X    artfp = Nullfp;
  759. X    UNLINK(artname);
  760. X     errno = ENOENT;        /* Simulate file-not-found */
  761. X        return Nullfp;
  762. X    }
  763. X
  764. X    for (;;) {
  765. X        if (get_server(ser_line, sizeof(ser_line)) < 0) {
  766. X        fprintf(stderr, "rrn: Unexpected close of server socket.\n");
  767. X        finalize(1);
  768. X    }
  769. X    if (ser_line[0] == '.' && ser_line[1] == '\0')
  770. X        break;
  771. X    fputs((ser_line[0] == '.' ? ser_line + 1 : ser_line), artfp);
  772. X    putc('\n', artfp);
  773. X    }
  774. X    openpart = function;
  775. X    if (function == GET_HEADER)
  776. X     putc('\n', artfp); /* req'd blank line after header */
  777. X    fseek(artfp, 0L, 0);        /* Then get back to the start */
  778. X    openart = artnum;
  779. X    return artfp;            /* and return either fp or NULL */
  780. X}
  781. X
  782. Xvoid
  783. Xnntpclose()
  784. X{
  785. X    char artname[32];            /* filename of current article */
  786. X    if (our_pid == 0)
  787. X    our_pid = getpid();
  788. X    sprintf(artname, "/tmp/rrn%ld.%ld", (long) openart, our_pid);
  789. X    UNLINK(artname);
  790. X}
  791. X#endif
  792. END_OF_FILE
  793.   if test 4969 -ne `wc -c <'artio.c'`; then
  794.     echo shar: \"'artio.c'\" unpacked with wrong size!
  795.   fi
  796.   # end of 'artio.c'
  797. fi
  798. if test -f 'backpage.c' -a "${1}" != "-c" ; then 
  799.   echo shar: Will not clobber existing file \"'backpage.c'\"
  800. else
  801.   echo shar: Extracting \"'backpage.c'\" \(2353 characters\)
  802.   sed "s/^X//" >'backpage.c' <<'END_OF_FILE'
  803. X/* $Header: backpage.c,v 4.3.3.2 91/01/16 02:29:46 davison Trn $
  804. X *
  805. X * $Log:    backpage.c,v $
  806. X * Revision 4.3.3.2  91/01/16  02:29:46  davison
  807. X * Integrated rn patches 48-54.
  808. X * 
  809. X * Revision 4.3.3.1  90/06/20  22:36:17  davison
  810. X * Initial Trn Release
  811. X * 
  812. X * Revision 4.3.2.1  90/11/22  16:08:00  sob
  813. X * Made changes to accomodate picky C precompilers
  814. X * 
  815. X * Revision 4.3  85/05/01  11:36:03  lwall
  816. X * Baseline for release with 4.3bsd.
  817. X * 
  818. X */
  819. X
  820. X#include "EXTERN.h"
  821. X#include "common.h"
  822. X#include "intrp.h"
  823. X#include "final.h"
  824. X#include "INTERN.h"
  825. X#include "backpage.h"
  826. X
  827. XART_LINE maxindx = -1;
  828. Xlong lseek();
  829. X
  830. Xvoid
  831. Xbackpage_init()
  832. X{
  833. X    char *varyname;
  834. X    
  835. X    varyname = filexp(VARYNAME);
  836. X    close(creat(varyname,0600));
  837. X    varyfd = open(varyname,2);
  838. X    UNLINK(varyname);
  839. X    if (varyfd < 0) {
  840. X    printf(cantopen,varyname) FLUSH;
  841. X    sig_catcher(0);
  842. X    }
  843. X    
  844. X}
  845. X
  846. X/* virtual array read */
  847. X
  848. XART_POS
  849. Xvrdary(indx)
  850. XART_LINE indx;
  851. X{
  852. X    int subindx;
  853. X    long offset;
  854. X
  855. X#ifdef DEBUGGING
  856. X    if (indx > maxindx) {
  857. X    printf("vrdary(%ld) > %ld\n",(long)indx, (long)maxindx) FLUSH;
  858. X    return 0;
  859. X    }
  860. X#endif
  861. X    if (indx < 0)
  862. X    return 0;
  863. X    subindx = indx % VARYSIZE;
  864. X    offset = (indx - subindx) * sizeof(varybuf[0]);
  865. X    if (offset != oldoffset) {
  866. X    if (oldoffset >= 0) {
  867. X#ifndef lint
  868. X        (void)lseek(varyfd,oldoffset,0);
  869. X        write(varyfd, (char *)varybuf,sizeof(varybuf));
  870. X#endif /* lint */
  871. X    }
  872. X#ifndef lint
  873. X    (void)lseek(varyfd,offset,0);
  874. X    read(varyfd,(char *)varybuf,sizeof(varybuf));
  875. X#endif /* lint */
  876. X    oldoffset = offset;
  877. X    }
  878. X    return varybuf[subindx];
  879. X}
  880. X
  881. X/* write to virtual array */
  882. X
  883. Xvoid
  884. Xvwtary(indx,newvalue)
  885. XART_LINE indx;
  886. XART_POS newvalue;
  887. X{
  888. X    int subindx;
  889. X    long offset;
  890. X
  891. X#ifdef DEBUGGING
  892. X    if (indx < 0)
  893. X    printf("vwtary(%ld)\n",(long)indx) FLUSH;
  894. X    if (!indx)
  895. X    maxindx = 0;
  896. X    if (indx > maxindx) {
  897. X    if (indx != maxindx + 1)
  898. X        printf("indx skipped %d-%d\n",maxindx+1,indx-1) FLUSH;
  899. X    maxindx = indx;
  900. X    }
  901. X#endif
  902. X    subindx = indx % VARYSIZE;
  903. X    offset = (indx - subindx) * sizeof(varybuf[0]);
  904. X    if (offset != oldoffset) {
  905. X    if (oldoffset >= 0) {
  906. X#ifndef lint
  907. X        (void)lseek(varyfd,oldoffset,0);
  908. X        write(varyfd,(char *)varybuf,sizeof(varybuf));
  909. X#endif /* lint */
  910. X    }
  911. X#ifndef lint
  912. X    (void)lseek(varyfd,offset,0);
  913. X    read(varyfd,(char *)varybuf,sizeof(varybuf));
  914. X#endif /* lint */
  915. X    oldoffset = offset;
  916. X    }
  917. X    varybuf[subindx] = newvalue;
  918. X}
  919. X
  920. END_OF_FILE
  921.   if test 2353 -ne `wc -c <'backpage.c'`; then
  922.     echo shar: \"'backpage.c'\" unpacked with wrong size!
  923.   fi
  924.   # end of 'backpage.c'
  925. fi
  926. if test -f 'getactive.c' -a "${1}" != "-c" ; then 
  927.   echo shar: Will not clobber existing file \"'getactive.c'\"
  928. else
  929.   echo shar: Extracting \"'getactive.c'\" \(1826 characters\)
  930.   sed "s/^X//" >'getactive.c' <<'END_OF_FILE'
  931. X/* $Header: getactive.c,v 1.2 89/11/28 01:50:22 sob Locked $
  932. X *
  933. X * $Log:    getactive.c,v $
  934. X * Revision 1.2  89/11/28  01:50:22  sob
  935. X * Changed so that it won't give makedepend problems with SERVER is not defined.
  936. X * 
  937. X * Revision 1.1  89/11/06  00:50:14  sob
  938. X * Initial revision
  939. X * 
  940. X *
  941. X */
  942. X#include <stdio.h>
  943. X#include "config.h"
  944. X#include "EXTERN.h"
  945. X#ifdef SERVER
  946. X#include "server.h"
  947. X#endif
  948. X
  949. Xmain(argc, argv)
  950. X    int        argc;
  951. X    char         *argv[];
  952. X{
  953. X    char        ser_line[256];
  954. X    int        response;
  955. X    register char    *server;
  956. X    register FILE    *actfp;
  957. X
  958. X    if (argc != 2) {
  959. X        fprintf(stderr, "Usage: getactive filename\n");
  960. X        exit(1);
  961. X    }
  962. X
  963. X    server = getserverbyfile(SERVER_FILE);
  964. X    if (server == NULL) {
  965. X        fprintf(stderr, "Couldn't get name of news server from %s\n",
  966. X            SERVER_FILE);
  967. X        fprintf(stderr,
  968. X      "Either fix this file, or put NNTPSERVER in your environment.\n");
  969. X        exit(1);
  970. X    }
  971. X
  972. X    response = server_init(server);
  973. X    if (response < 0) {
  974. X        fprintf(stderr,
  975. X            "getactive: Can't get active file from server %s.\n",
  976. X                server);
  977. X        exit(1);
  978. X    }
  979. X
  980. X    if (handle_server_response(response, server) < 0)
  981. X        exit(1);
  982. X
  983. X    put_server("LIST");    /* tell server we want the active file */
  984. X    (void) get_server(ser_line, sizeof(ser_line));
  985. X    if (*ser_line != CHAR_OK) {        /* and then see if that's ok */
  986. X        fprintf(stderr,
  987. X            "getactive: Can't get active file from server.\n");
  988. X        fprintf(stderr, "Server said: %s\n", ser_line);
  989. X        exit(1);
  990. X    }
  991. X
  992. X    actfp = fopen(argv[1], "w");        /* and get ready */
  993. X    if (actfp == NULL) {
  994. X        close_server();
  995. X        perror(argv[1]);
  996. X        exit(1);
  997. X    }
  998. X
  999. X    while (get_server(ser_line, sizeof(ser_line)) >= 0) {  /* while */
  1000. X        if (ser_line[0] == '.')        /* there's another line */
  1001. X            break;            /* get it and write it to */
  1002. X        if (actfp != NULL) {        /* the temporary active file */
  1003. X            fputs(ser_line, actfp);
  1004. X            putc('\n', actfp);
  1005. X        }
  1006. X    }
  1007. X
  1008. X    (void) fclose(actfp);
  1009. X    close_server();
  1010. X}
  1011. END_OF_FILE
  1012.   if test 1826 -ne `wc -c <'getactive.c'`; then
  1013.     echo shar: \"'getactive.c'\" unpacked with wrong size!
  1014.   fi
  1015.   # end of 'getactive.c'
  1016. fi
  1017. if test -f 'makedepend.SH' -a "${1}" != "-c" ; then 
  1018.   echo shar: Will not clobber existing file \"'makedepend.SH'\"
  1019. else
  1020.   echo shar: Extracting \"'makedepend.SH'\" \(2653 characters\)
  1021.   sed "s/^X//" >'makedepend.SH' <<'END_OF_FILE'
  1022. Xcase $CONFIG in
  1023. X    '') . ./config.sh ;;
  1024. Xesac
  1025. Xecho "Extracting makedepend (with variable substitutions)"
  1026. X$spitshell >makedepend <<!GROK!THIS!
  1027. X$startsh
  1028. X# $Header: makedepend.SH,v 4.3.3.2 91/01/16 02:48:09 davison Trn $
  1029. X#
  1030. X# $Log:    makedepend.SH,v $
  1031. X# Revision 4.3.3.2  91/01/16  02:48:09  davison
  1032. X# Integrated rn patches 48-54.
  1033. X# 
  1034. X# Revision 4.3.3.1  90/06/20  22:38:14  davison
  1035. X# Initial Trn Release
  1036. X# 
  1037. X# Revision 4.3.2.3  90/10/30  22:46:14  sob
  1038. X# Made minor changes to the send command to work better on Apollos.
  1039. X# 
  1040. X# Revision 4.3.2.2  90/04/21  14:24:58  sob
  1041. X# Added a fix to deal with XENIX cc -E output.
  1042. X# 
  1043. X# Revision 4.3.2.1  89/12/17  02:52:46  sob
  1044. X# Will only read config.sh from local directory.
  1045. X# 
  1046. X# Revision 4.3.1.2  85/05/13  15:53:42  lwall
  1047. X# Made cpp look in /usr/local/include too.
  1048. X# 
  1049. X# Revision 4.3.1.1  85/05/10  11:35:10  lwall
  1050. X# Branch for patches.
  1051. X# 
  1052. X# Revision 4.3  85/05/01  11:42:26  lwall
  1053. X# Baseline for release with 4.3bsd.
  1054. X# 
  1055. X
  1056. Xexport PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh \$0; kill \$\$)
  1057. X
  1058. X$cat /dev/null >.deptmp
  1059. X$echo "(Note: this is going to take a while.)"
  1060. X$rm -f X*.c
  1061. Xfor file in *.c; do
  1062. X    filebase=\`basename \$file .c\`
  1063. X    $echo "Finding dependencies for \$filebase.o."
  1064. X    $sed -n <\$file >X\$file \\
  1065. X    -e "/^\${filebase}_init(/q" \\
  1066. X    -e '/^#/{' \\
  1067. X    -e 's|/\*.*$||' \\
  1068. X    -e p \\
  1069. X    -e '}'
  1070. X    $cpp -I/usr/local/include X\$file | $sed  \\
  1071. X    -e '/^# *line/s/line//' \
  1072. X    -e '/^# *[0-9]/!d' \\
  1073. X    -e 's/^.*"\(.*\)".*\$/'\$filebase'.o: \1/' \\
  1074. X    -e 's|: \./|: |' \\
  1075. X    -e 's|: X|: |' | \\
  1076. X    $uniq | $sort | $uniq >> .deptmp
  1077. Xdone
  1078. X
  1079. Xfor file in *.SH; do
  1080. X    $echo \`basename \$file .SH\`: \$file config.sh \; /bin/sh \$file >> .deptmp
  1081. Xdone
  1082. X
  1083. X$sed <Makefile >Makefile.new -e '1,/^# AUTOMATICALLY/!d'
  1084. X
  1085. Xif $test -s .deptmp; then
  1086. X    echo "Updating Makefile..."
  1087. X    echo "# If this runs make out of memory, delete /usr/include lines." >>Makefile.new
  1088. X    $sed -e 's/\\\$/\$\$/g' .deptmp >>Makefile.new
  1089. Xelse
  1090. X    $echo "You don't seem to have a proper C preprocessor.  Using grep instead."
  1091. X    $egrep '^#include ' *.c *.h >.deptmp
  1092. X    echo "Updating Makefile..."
  1093. X    <.deptmp $sed -n 's|c:#include "\(.*\)".*\$\$|o: \1|p' >> Makefile.new
  1094. X    <.deptmp $sed -n 's|c:#include <\(.*\)>.*\$\$|o: /usr/include/\1|p' >> Makefile.new
  1095. X    <.deptmp $sed -n 's|h:#include "\(.*\)".*\$\$|h: \1|p' >> Makefile.new
  1096. X    <.deptmp $sed -n 's|h:#include <\(.*\)>.*\$\$|h: /usr/include/\1|p' >> Makefile.new
  1097. Xfi
  1098. X$mv Makefile Makefile.old
  1099. X$mv Makefile.new Makefile
  1100. X$echo "# WARNING: Put nothing here or make depend will gobble it up!" >> Makefile
  1101. Xrm .deptmp X*.c
  1102. X
  1103. X!GROK!THIS!
  1104. X$eunicefix makedepend
  1105. Xchmod 755 makedepend
  1106. END_OF_FILE
  1107.   if test 2653 -ne `wc -c <'makedepend.SH'`; then
  1108.     echo shar: \"'makedepend.SH'\" unpacked with wrong size!
  1109.   fi
  1110.   chmod +x 'makedepend.SH'
  1111.   # end of 'makedepend.SH'
  1112. fi
  1113. if test -f 'mbox.saver.SH' -a "${1}" != "-c" ; then 
  1114.   echo shar: Will not clobber existing file \"'mbox.saver.SH'\"
  1115. else
  1116.   echo shar: Extracting \"'mbox.saver.SH'\" \(1806 characters\)
  1117.   sed "s/^X//" >'mbox.saver.SH' <<'END_OF_FILE'
  1118. Xcase $CONFIG in
  1119. X    '') . ./config.sh ;;
  1120. Xesac
  1121. Xecho "Extracting mbox.saver (with variable substitutions)"
  1122. X$spitshell >mbox.saver <<!GROK!THIS!
  1123. X$startsh
  1124. X# $Header: mbox.saver.SH,v 4.3.3.1 90/08/20 16:30:28 davison Trn $
  1125. X# 
  1126. X# $Log:    mbox.saver.SH,v $
  1127. X# Revision 4.3.3.1  90/08/20  16:30:28  davison
  1128. X# Added support for MMDF format mailboxes.
  1129. X# 
  1130. X# Revision 4.3.2.3  90/11/22  14:28:27  sob
  1131. X# Changed . config.sh to . ./config.sh
  1132. X# 
  1133. X# Revision 4.3.2.2  90/03/17  20:44:54  sob
  1134. X# Modify Article header to place the colon after Article.
  1135. X# 
  1136. X# Revision 4.3.2.1  89/11/28  00:05:47  sob
  1137. X# Branch for RN/RRN combo patches
  1138. X# 
  1139. X# Revision 4.3.1.2  85/05/20  15:55:37  lwall
  1140. X# Turned $5 into \$5.
  1141. X# 
  1142. X# Revision 4.3.1.1  85/05/10  11:35:30  lwall
  1143. X# Branch for patches.
  1144. X# 
  1145. X# Revision 4.3  85/05/01  11:42:51  lwall
  1146. X# Baseline for release with 4.3bsd.
  1147. X# 
  1148. X# 
  1149. X#    Arguments:
  1150. X#    1 Full name of article (%A)
  1151. X#    2 Public news spool directory (%P)
  1152. X#    3 Directory of current newsgroup (%c)
  1153. X#    4 Article number (%a)
  1154. X#    5 Where in article to start (%B)
  1155. X#    6 Newsgroup name (%C)
  1156. X#    7 Save destination (%b)
  1157. X#    8 First line of message, normally From...
  1158. X#
  1159. Xexport PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh \$0; kill \$\$)
  1160. X
  1161. X!GROK!THIS!
  1162. Xcase $mboxchar in
  1163. X"$CTRLA")
  1164. X    $spitshell >>mbox.saver <<!GROK!THIS!
  1165. X( $echo "$CTRLA$CTRLA$CTRLA$CTRLA"
  1166. X  if $test "\$5" = 0 -a ! "\$4" = 0 ; then
  1167. X    $echo "Article: \$4 of \$6"
  1168. X  fi
  1169. X  $tail +\$5c \$1
  1170. X  $echo ""
  1171. X  $echo ""
  1172. X  $echo "$CTRLA$CTRLA$CTRLA$CTRLA" ) >> \$7
  1173. X!GROK!THIS!
  1174. X    ;;
  1175. X*)
  1176. X    $spitshell >>mbox.saver <<!GROK!THIS!
  1177. X( $echo "\$8"
  1178. X  if $test "\$5" = 0 -a ! "\$4" = 0 ; then
  1179. X    $echo "Article: \$4 of \$6"
  1180. X  fi
  1181. X  $tail +\$5c \$1 | $sed "s/^From />From /"
  1182. X  $echo ""
  1183. X  $echo "" ) >> \$7
  1184. X!GROK!THIS!
  1185. X    ;;
  1186. Xesac
  1187. X$eunicefix mbox.saver
  1188. Xchmod 755 mbox.saver
  1189. END_OF_FILE
  1190.   if test 1806 -ne `wc -c <'mbox.saver.SH'`; then
  1191.     echo shar: \"'mbox.saver.SH'\" unpacked with wrong size!
  1192.   fi
  1193.   chmod +x 'mbox.saver.SH'
  1194.   # end of 'mbox.saver.SH'
  1195. fi
  1196. if test -f 'mthreads.h' -a "${1}" != "-c" ; then 
  1197.   echo shar: Will not clobber existing file \"'mthreads.h'\"
  1198. else
  1199.   echo shar: Extracting \"'mthreads.h'\" \(1581 characters\)
  1200.   sed "s/^X//" >'mthreads.h' <<'END_OF_FILE'
  1201. X/* $Header: mthreads.h,v 4.3.3.3 91/01/16 03:16:33 davison Trn $
  1202. X**
  1203. X** $Log:    mthreads.h,v $
  1204. X** Revision 4.3.3.3  91/01/16  03:16:33  davison
  1205. X** Added optional prototyping.
  1206. X** 
  1207. X** Revision 4.3.3.2  90/08/20  16:44:29  davison
  1208. X** New entries for new command-line interface.
  1209. X** 
  1210. X** Revision 4.3.3.1  90/06/20  22:55:27  davison
  1211. X** Initial Trn Release
  1212. X** 
  1213. X*/
  1214. X
  1215. X#ifdef lint
  1216. X#include "mt-lint.h"
  1217. X#endif
  1218. X#include "threads.h"
  1219. X
  1220. XEXT TOTAL total;
  1221. X
  1222. XEXT int processed_groups;
  1223. XEXT int added_articles, added_count;
  1224. XEXT int expired_articles, expired_count;
  1225. XEXT bool extra_expire INIT(FALSE);
  1226. XEXT int caught_interrupt INIT(0);
  1227. X
  1228. XEXT char *strings INIT(0);
  1229. XEXT WORD *subject_cnts INIT(0);
  1230. XEXT WORD *author_cnts INIT(0);
  1231. XEXT WORD *ids INIT(0);
  1232. X
  1233. XEXT SUBJECT **subject_array;
  1234. XEXT ROOT **root_array;
  1235. XEXT AUTHOR **author_array;
  1236. XEXT ARTICLE **article_array;
  1237. X
  1238. XEXT PACKED_ROOT p_root;
  1239. XEXT PACKED_ARTICLE p_article;
  1240. X
  1241. XEXT ROOT *root_root;
  1242. XEXT AUTHOR *author_root;
  1243. X
  1244. X#ifndef DOINIT
  1245. XEXT DOMAIN unk_domain;
  1246. X#else
  1247. XDOMAIN unk_domain = {
  1248. X    ".unknown.", NULL, NULL
  1249. X};
  1250. X#endif
  1251. X
  1252. Xint ngmatch ANSI((char *,char *));
  1253. Xint onepatmatch ANSI((char *,char *));
  1254. X
  1255. Xvoid log_entry();
  1256. Xvoid log_error();
  1257. X
  1258. Xvoid mybytemap ANSI((BMAP *));
  1259. Xint read_data ANSI((void));
  1260. Xint write_data ANSI((char *));
  1261. Xvoid dont_read_data ANSI((int));
  1262. X
  1263. Xvoid process_articles ANSI((ART_NUM,ART_NUM));
  1264. X
  1265. Xchar *thread_name ANSI((char *));
  1266. Xchar *file_exp ANSI((char *));
  1267. Xchar *savestr ANSI((char *));
  1268. X
  1269. X#ifndef lint
  1270. Xchar *safemalloc ANSI((MEM_SIZE));
  1271. Xvoid free();
  1272. Xvoid safefree();
  1273. X#endif
  1274. X
  1275. Xtime_t getdate ANSI((char *,time_t,long));
  1276. X
  1277. X#define Nullart Null(ARTICLE*)
  1278. END_OF_FILE
  1279.   if test 1581 -ne `wc -c <'mthreads.h'`; then
  1280.     echo shar: \"'mthreads.h'\" unpacked with wrong size!
  1281.   fi
  1282.   # end of 'mthreads.h'
  1283. fi
  1284. if test -f 'ndir.c' -a "${1}" != "-c" ; then 
  1285.   echo shar: Will not clobber existing file \"'ndir.c'\"
  1286. else
  1287.   echo shar: Extracting \"'ndir.c'\" \(2539 characters\)
  1288.   sed "s/^X//" >'ndir.c' <<'END_OF_FILE'
  1289. X/* $Header: ndir.c,v 4.3.3.2 91/01/16 03:18:03 davison Trn $
  1290. X *
  1291. X * $Log:    ndir.c,v $
  1292. X * Revision 4.3.3.2  91/01/16  03:18:03  davison
  1293. X * Integrated rn patches 48-54.
  1294. X * 
  1295. X * Revision 4.3.3.1  90/06/20  22:38:20  davison
  1296. X * Initial Trn Release
  1297. X * 
  1298. X * Revision 4.3.1.6  90/11/22  16:08:50  sob
  1299. X * Added changes to accomodate pick C preprocessors.
  1300. X * 
  1301. X * Revision 4.3.1.5  90/03/22  23:04:47  sob
  1302. X * Fixes provided by Wayne Davison <drivax!davison>
  1303. X * 
  1304. X * Revision 4.3.1.3  85/05/23  11:19:24  lwall
  1305. X * Oops, shouldn't have included sys/types.h again.
  1306. X * 
  1307. X * Revision 4.3.1.2  85/05/15  14:46:00  lwall
  1308. X * Changed short to ino_t, which may be ushort on some systems.
  1309. X * 
  1310. X * Revision 4.3.1.1  85/05/10  11:35:34  lwall
  1311. X * Branch for patches.
  1312. X * 
  1313. X * Revision 4.3  85/05/01  11:42:55  lwall
  1314. X * Baseline for release with 4.3bsd.
  1315. X * 
  1316. X */
  1317. X
  1318. X#include "EXTERN.h"
  1319. X#include "common.h"
  1320. X#include "INTERN.h"
  1321. X#include "ndir.h"
  1322. X
  1323. X#ifdef USENDIR
  1324. X/*
  1325. X * support for Berkeley directory reading routine on a V7 file system
  1326. X */
  1327. X
  1328. X/*
  1329. X * open a directory.
  1330. X */
  1331. XDIR *
  1332. Xopendir(name)
  1333. Xchar *name;
  1334. X{
  1335. X    register DIR *dirp;
  1336. X    register int fd;
  1337. X    char *malloc();
  1338. X
  1339. X    if ((fd = open(name, 0)) == -1)
  1340. X        return NULL;
  1341. X    if ((dirp = (DIR *)malloc(sizeof(DIR))) == NULL) {
  1342. X        close (fd);
  1343. X        return NULL;
  1344. X    }
  1345. X    dirp->dd_fd = fd;
  1346. X    dirp->dd_loc = 0;
  1347. X    return dirp;
  1348. X}
  1349. X
  1350. X/*
  1351. X * read an old style directory entry and present it as a new one
  1352. X */
  1353. X#ifndef pyr
  1354. X#define    ODIRSIZ    14
  1355. X
  1356. Xstruct    olddirect {
  1357. X    ino_t    od_ino;
  1358. X    char    od_name[ODIRSIZ];
  1359. X};
  1360. X#else    an Pyramid in the ATT universe
  1361. X#define    ODIRSIZ    248
  1362. X
  1363. Xstruct    olddirect {
  1364. X    long    od_ino;
  1365. X    short    od_fill1, od_fill2;
  1366. X    char    od_name[ODIRSIZ];
  1367. X};
  1368. X#endif
  1369. X
  1370. X/*
  1371. X * get next entry in a directory.
  1372. X */
  1373. Xstruct direct *
  1374. Xreaddir(dirp)
  1375. Xregister DIR *dirp;
  1376. X{
  1377. X    register struct olddirect *dp;
  1378. X    static struct direct dir;
  1379. X
  1380. X    for (;;) {
  1381. X        if (dirp->dd_loc == 0) {
  1382. X            dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf,
  1383. X                DIRBLKSIZ);
  1384. X            if (dirp->dd_size <= 0)
  1385. X                return NULL;
  1386. X        }
  1387. X        if (dirp->dd_loc >= dirp->dd_size) {
  1388. X            dirp->dd_loc = 0;
  1389. X            continue;
  1390. X        }
  1391. X        dp = (struct olddirect *)(dirp->dd_buf + dirp->dd_loc);
  1392. X        dirp->dd_loc += sizeof(struct olddirect);
  1393. X        if (dp->od_ino == 0)
  1394. X            continue;
  1395. X        dir.d_ino = dp->od_ino;
  1396. X        strncpy(dir.d_name, dp->od_name, ODIRSIZ);
  1397. X        dir.d_name[ODIRSIZ] = '\0'; /* insure null termination */
  1398. X        dir.d_namlen = strlen(dir.d_name);
  1399. X        dir.d_reclen = DIRSIZ(&dir);
  1400. X        return (&dir);
  1401. X    }
  1402. X}
  1403. X
  1404. X/*
  1405. X * close a directory.
  1406. X */
  1407. Xvoid
  1408. Xclosedir(dirp)
  1409. Xregister DIR *dirp;
  1410. X{
  1411. X    close(dirp->dd_fd);
  1412. X    dirp->dd_fd = -1;
  1413. X    dirp->dd_loc = 0;
  1414. X    free(dirp);
  1415. X}
  1416. X
  1417. X#endif /* USENDIR */
  1418. END_OF_FILE
  1419.   if test 2539 -ne `wc -c <'ndir.c'`; then
  1420.     echo shar: \"'ndir.c'\" unpacked with wrong size!
  1421.   fi
  1422.   # end of 'ndir.c'
  1423. fi
  1424. if test -f 'ndir.h' -a "${1}" != "-c" ; then 
  1425.   echo shar: Will not clobber existing file \"'ndir.h'\"
  1426. else
  1427.   echo shar: Extracting \"'ndir.h'\" \(1640 characters\)
  1428.   sed "s/^X//" >'ndir.h' <<'END_OF_FILE'
  1429. X/* $Header: ndir.h,v 4.3.3.1 91/01/16 03:18:04 davison Trn $
  1430. X *
  1431. X * $Log:    ndir.h,v $
  1432. X * Revision 4.3.3.1  91/01/16  03:18:04  davison
  1433. X * Added optional prototyping.
  1434. X * 
  1435. X * Revision 4.3.2.1  90/04/17  15:28:13  sob
  1436. X * Altered to include correct directory include file.
  1437. X * 
  1438. X * Revision 4.3  85/05/01  11:43:00  lwall
  1439. X * Baseline for release with 4.3bsd.
  1440. X * 
  1441. X */
  1442. X
  1443. X#ifdef LIBNDIR
  1444. X#   include <ndir.h>
  1445. X#else
  1446. X#   ifndef USENDIR
  1447. X#    include DIRINC
  1448. X#   else
  1449. X
  1450. X#ifndef DEV_BSIZE
  1451. X#define    DEV_BSIZE    512
  1452. X#endif
  1453. X#define DIRBLKSIZ    DEV_BSIZE
  1454. X#define    MAXNAMLEN    255
  1455. X
  1456. Xstruct    direct {
  1457. X    long    d_ino;            /* inode number of entry */
  1458. X    short    d_reclen;        /* length of this record */
  1459. X    short    d_namlen;        /* length of string in d_name */
  1460. X    char    d_name[MAXNAMLEN + 1];    /* name must be no longer than this */
  1461. X};
  1462. X
  1463. X/*
  1464. X * The DIRSIZ macro gives the minimum record length which will hold
  1465. X * the directory entry.  This requires the amount of space in struct direct
  1466. X * without the d_name field, plus enough space for the name with a terminating
  1467. X * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
  1468. X */
  1469. X#undef DIRSIZ
  1470. X#define DIRSIZ(dp) \
  1471. X    ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
  1472. X
  1473. X/*
  1474. X * Definitions for library routines operating on directories.
  1475. X */
  1476. Xtypedef struct _dirdesc {
  1477. X    int    dd_fd;
  1478. X    long    dd_loc;
  1479. X    long    dd_size;
  1480. X    char    dd_buf[DIRBLKSIZ];
  1481. X} DIR;
  1482. X#ifndef NULL
  1483. X#define NULL 0
  1484. X#endif
  1485. Xextern    DIR *opendir ANSI((char *));
  1486. Xextern    struct direct *readdir ANSI((DIR *));
  1487. Xextern    long telldir ANSI((DIR *));
  1488. Xextern    void seekdir ANSI((DIR *));
  1489. X#define rewinddir(dirp)    seekdir((dirp), (long)0)
  1490. Xextern    void closedir ANSI((DIR *));
  1491. X
  1492. X#   endif
  1493. X#endif
  1494. END_OF_FILE
  1495.   if test 1640 -ne `wc -c <'ndir.h'`; then
  1496.     echo shar: \"'ndir.h'\" unpacked with wrong size!
  1497.   fi
  1498.   # end of 'ndir.h'
  1499. fi
  1500. if test -f 'newsetup.1' -a "${1}" != "-c" ; then 
  1501.   echo shar: Will not clobber existing file \"'newsetup.1'\"
  1502. else
  1503.   echo shar: Extracting \"'newsetup.1'\" \(1599 characters\)
  1504.   sed "s/^X//" >'newsetup.1' <<'END_OF_FILE'
  1505. X''' $Header: newsetup.1,v 4.3 85/05/01 11:43:22 lwall Exp $
  1506. X''' 
  1507. X''' $Log:    newsetup.1,v $
  1508. X''' Revision 4.3  85/05/01  11:43:22  lwall
  1509. X''' Baseline for release with 4.3bsd.
  1510. X''' 
  1511. X''' 
  1512. X.de Sh
  1513. X.br
  1514. X.ne 5
  1515. X.PP
  1516. X\fB\\$1\fR
  1517. X.PP
  1518. X..
  1519. X.de Sp
  1520. X.if t .sp .5v
  1521. X.if n .sp
  1522. X..
  1523. X'''
  1524. X'''     Set up \*(-- to give an unbreakable dash;
  1525. X'''     string Tr holds user defined translation string.
  1526. X'''     Bell System Logo is used as a dummy character.
  1527. X'''
  1528. X.ie n \{\
  1529. X.tr \(bs-\*(Tr
  1530. X.ds -- \(bs-
  1531. X.if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch
  1532. X.if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch
  1533. X.ds L" ""
  1534. X.ds R" ""
  1535. X.ds L' '
  1536. X.ds R' '
  1537. X'br\}
  1538. X.el\{\
  1539. X.ds -- \(em\|
  1540. X.tr \*(Tr
  1541. X.ds L" ``
  1542. X.ds R" ''
  1543. X.ds L' `
  1544. X.ds R' '
  1545. X'br\}
  1546. X.TH NEWSETUP 1 LOCAL
  1547. X.SH NAME
  1548. Xnewsetup - a program to set up a .newsrc file
  1549. X.SH SYNOPSIS
  1550. X.B newsetup
  1551. X.SH DESCRIPTION
  1552. XThe
  1553. X.I newsetup
  1554. Xprogram creates a new .newsrc file containing all of the currently active
  1555. Xnewsgroups.
  1556. XIt tries to put them in a reasonable order, i.e. local newsgroups earlier,
  1557. Xbut you'll probably want to change the ordering anyway (if you use
  1558. X.IR rn )
  1559. Xin order to put interesting newsgroups first.
  1560. XIf you already have a .newsrc, it will be backed up with the name
  1561. X\*(L".oldnewsrc\*(R".
  1562. X.SH ENVIRONMENT
  1563. X.IP DOTDIR 8
  1564. XWhere to put your .newsrc, if not in your home directory.
  1565. X.Sp
  1566. XDefault: $HOME
  1567. X.IP HOME 8
  1568. XYour home directory.
  1569. X.Sp
  1570. XDefault: $LOGDIR
  1571. X.IP LOGDIR 8
  1572. XYour home directory if HOME is undefined.
  1573. X.SH FILES
  1574. X/usr/lib/news/active or a reasonable facsimile
  1575. X.br
  1576. X${DOTDIR-{$HOME-$LOGDIR}}/.newsrc
  1577. X.SH SEE ALSO
  1578. Xrn(1), newsrc(5)
  1579. X.SH DIAGNOSTICS
  1580. X.SH BUGS
  1581. END_OF_FILE
  1582.   if test 1599 -ne `wc -c <'newsetup.1'`; then
  1583.     echo shar: \"'newsetup.1'\" unpacked with wrong size!
  1584.   fi
  1585.   # end of 'newsetup.1'
  1586. fi
  1587. if test -f 'newsetup.SH' -a "${1}" != "-c" ; then 
  1588.   echo shar: Will not clobber existing file \"'newsetup.SH'\"
  1589. else
  1590.   echo shar: Extracting \"'newsetup.SH'\" \(3690 characters\)
  1591.   sed "s/^X//" >'newsetup.SH' <<'END_OF_FILE'
  1592. Xcase $CONFIG in
  1593. X    '') . ./config.sh ;;
  1594. Xesac
  1595. Xecho "Extracting newsetup (with variable substitutions)"
  1596. X$spitshell >newsetup <<!GROK!THIS!
  1597. X$startsh
  1598. X
  1599. X# $Header: newsetup.SH,v 4.3.3.1 91/01/16 03:18:11 davison Trn $
  1600. X# 
  1601. X# $Log:    newsetup.SH,v $
  1602. X# Revision 4.3.3.1  91/01/16  03:18:11  davison
  1603. X# Integrated rn patches 48-54.
  1604. X# 
  1605. X# Revision 4.3.2.8  90/11/22  13:26:55  sob
  1606. X# Purged unneeded code.
  1607. X# 
  1608. X# Revision 4.3.2.7  90/03/17  20:34:48  sob
  1609. X# Remove the /tmp/n.* files created when generating the .newsrc.
  1610. X# 
  1611. X# Revision 4.3.2.6  90/03/17  17:26:42  sob
  1612. X# Some versions of sed only take 9 wfiles.
  1613. X# 
  1614. X# Revision 4.3.2.5  89/11/28  01:15:32  sob
  1615. X# Fixed a bug that caused the active file to be removed on non-NNTP-based
  1616. X# systems.
  1617. X# 
  1618. X# Revision 4.3.2.4  89/11/28  00:31:20  sob
  1619. X# Changed news.announce.newuser to news.announce.newusers.
  1620. X# 
  1621. X# Revision 4.3.2.3  89/11/08  01:13:15  sob
  1622. X# Finished modifications to make work with RN and RRN
  1623. X#
  1624. X# Revision 4.3.2.2  89/11/07  23:25:50  sob
  1625. X#
  1626. X# Added support such that RN and RRN can be made from the same sources.
  1627. X# 
  1628. X# Revision 4.3.1.2  86/09/05  15:41:04  lwall
  1629. X# Changes for newsgroup renaming.
  1630. X# 
  1631. X# Revision 4.3.1.1  85/05/10  11:35:43  lwall
  1632. X# Branch for patches.
  1633. X# 
  1634. X# Revision 4.3  85/05/01  11:43:05  lwall
  1635. X# Baseline for release with 4.3bsd.
  1636. X# 
  1637. X
  1638. Xexport PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh \$0; kill \$\$)
  1639. X
  1640. X: syntax: newsetup
  1641. X
  1642. X: System dependencies
  1643. X: You will want to change the definitions below to reflect the distribution
  1644. X: areas around you.  If you have more areas than this you will need to modify
  1645. X: the sed below.
  1646. X
  1647. Xlocorg="$locpref"
  1648. Xorganization="$orgpref"
  1649. Xcity="$citypref"
  1650. Xstate="$statepref"
  1651. Xcntry="$cntrypref"
  1652. Xcont="$contpref"
  1653. X#NORMALactive="${active-/usr/lib/news/active}"
  1654. X#NNTPactive="/tmp/active.\$\$"
  1655. X
  1656. Xdotdir="\${DOTDIR-\${HOME-\$LOGDIR}}"
  1657. X$rm -f \$dotdir/.oldnewsrc
  1658. X$echo "Creating .newsrc in \$dotdir to be used by news programs."
  1659. X#NNTPrnlib=$rnlib
  1660. X#NNTPcase \$rnlib in
  1661. X#NNTP~*) rnlib=\`$filexp \$rnlib\` ;;
  1662. X#NNTPesac
  1663. X#NNTP\$rnlib/getactive \$active
  1664. X#NORMALcase \$active in
  1665. X#NORMAL~*) active=\`$filexp \$active\` ;;
  1666. X#NORMALesac
  1667. X
  1668. Xif $test -s \$dotdir/.newsrc ; then
  1669. X    $echo "Saving your current .newsrc as .oldnewsrc..."
  1670. X    $mv -f \$dotdir/.newsrc \$dotdir/.oldnewsrc
  1671. Xfi
  1672. X
  1673. X: newsrc order determined here
  1674. X
  1675. X$sed <\$active '
  1676. X    /^to\./d
  1677. X    / [^mny][^ ]*$/d
  1678. X    s/ .*//
  1679. X    s/^/ /
  1680. X    s/^ '\$locorg'\./01&/
  1681. X    s/^ '\$organization'\./02&/
  1682. X    s/^ '\$city'\./03&/
  1683. X    s/^ '\$state'\./04&/
  1684. X    s/^ '\$cntry'\./05&/
  1685. X    s/^ '\$cont'\./06&/
  1686. X    s/^ news\./07&/
  1687. X    s/^ comp\./08&/
  1688. X    s/^ sci\./09&/
  1689. X    s/^ rec\./10&/
  1690. X    s/^ soc\./11&/
  1691. X    s/^ talk\./13&/
  1692. X    s/^ control\$/14&/
  1693. X    s/^ junk\$/14&/
  1694. X    s/^ test\$/14&/
  1695. X    /\.test\$/s/^[0-9]*/14/
  1696. X    s/^ .*\./12&/
  1697. X    s/^ /00&/
  1698. X' |
  1699. X$sort -u |
  1700. X$sed '
  1701. X    /^14 /!s/\$/:/
  1702. X    /^14 /s/\$/!/
  1703. X    s/^[0-9][0-9] //
  1704. X' >\$dotdir/.newsrc
  1705. X
  1706. X#NNTP$rm -f \$active
  1707. X$rm -f /tmp/n.misc\$\$ /tmp/n.sci\$\$ /tmp/n.soc\$\$ /tmp/n.news\$\$ /tmp/n.comp\$\$
  1708. X$rm -f /tmp/n.\$cont\$\$ /tmp/n.\$city\$\$ /tmp/n.\$cntry\$\$ /tmp/n.\$state\$\$
  1709. X$rm -f /tmp/n.to\$\$ /tmp/n.\$organization\$\$ /tmp/n.\$locorg\$\$ /tmp/n.test\$\$
  1710. X$rm -f /tmp/n.tmp\$\$ /tmp/n.local\$\$ /tmp/n.rec\$\$
  1711. X
  1712. X$cat <<'EOH'
  1713. XDone.
  1714. X
  1715. XIf you have never used the news system before, you may find the articles
  1716. Xin news.announce.newusers to be helpful.  There is also a manual entry for rn.
  1717. X
  1718. XTo get rid of newsgroups you aren't interested in, use the 'u' command.
  1719. XType h for help at any time while running rn.
  1720. XEOH
  1721. X!GROK!THIS!
  1722. Xcase "$isrrn" in
  1723. Xdefine)  sed < newsetup -e '/^#NNTP/s/^#NNTP//' -e '/^#NORMAL/d' > newsetup.new ;;
  1724. X*) sed < newsetup -e '/^#NNTP/d' -e '/^#NORMAL/s/^#NORMAL//' > newsetup.new ;;
  1725. Xesac
  1726. Xmv newsetup.new newsetup
  1727. X$eunicefix newsetup
  1728. Xchmod 755 newsetup
  1729. END_OF_FILE
  1730.   if test 3690 -ne `wc -c <'newsetup.SH'`; then
  1731.     echo shar: \"'newsetup.SH'\" unpacked with wrong size!
  1732.   fi
  1733.   chmod +x 'newsetup.SH'
  1734.   # end of 'newsetup.SH'
  1735. fi
  1736. if test -f 'newsgroups.1' -a "${1}" != "-c" ; then 
  1737.   echo shar: Will not clobber existing file \"'newsgroups.1'\"
  1738. else
  1739.   echo shar: Extracting \"'newsgroups.1'\" \(1706 characters\)
  1740.   sed "s/^X//" >'newsgroups.1' <<'END_OF_FILE'
  1741. X''' $Header: newsgroups.1,v 4.3 85/05/01 11:43:32 lwall Exp $
  1742. X''' 
  1743. X''' $Log:    newsgroups.1,v $
  1744. X''' Revision 4.3  85/05/01  11:43:32  lwall
  1745. X''' Baseline for release with 4.3bsd.
  1746. X''' 
  1747. X''' 
  1748. X.de Sh
  1749. X.br
  1750. X.ne 5
  1751. X.PP
  1752. X\fB\\$1\fR
  1753. X.PP
  1754. X..
  1755. X.de Sp
  1756. X.if t .sp .5v
  1757. X.if n .sp
  1758. X..
  1759. X'''
  1760. X'''     Set up \*(-- to give an unbreakable dash;
  1761. X'''     string Tr holds user defined translation string.
  1762. X'''     Bell System Logo is used as a dummy character.
  1763. X'''
  1764. X.ie n \{\
  1765. X.tr \(bs-\*(Tr
  1766. X.ds -- \(bs-
  1767. X.if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch
  1768. X.if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch
  1769. X.ds L" ""
  1770. X.ds R" ""
  1771. X.ds L' '
  1772. X.ds R' '
  1773. X'br\}
  1774. X.el\{\
  1775. X.ds -- \(em\|
  1776. X.tr \*(Tr
  1777. X.ds L" ``
  1778. X.ds R" ''
  1779. X.ds L' `
  1780. X.ds R' '
  1781. X'br\}
  1782. X.TH NEWSGROUPS 1 LOCAL
  1783. X.SH NAME
  1784. Xnewsgroups - a program to list unsubscribed newsgroups.
  1785. X.SH SYNOPSIS
  1786. X.B newsgroups pattern flag
  1787. X.SH DESCRIPTION
  1788. XThe
  1789. X.I newsgroups
  1790. Xprogram compares your .newsrc file with the file of active newsgroups,
  1791. Xand prints a list of unsubscribed newsgroups matching pattern.
  1792. XIf the second argument \*(L"flag\*(R" is present, only newsgroups not
  1793. Xfound in your .newsrc are listed, and the display is not paged.
  1794. XIf the second argument is missing, the display is paged, and an additional
  1795. Xlist of unsubscribed newsgroups occurring in your .newsrc is printed.
  1796. X.SH ENVIRONMENT
  1797. X.IP DOTDIR 8
  1798. XWhere to find your .newsrc, if not in your home directory.
  1799. X.Sp
  1800. XDefault: $HOME
  1801. X.IP HOME 8
  1802. XYour home directory.
  1803. X.Sp
  1804. XDefault: $LOGDIR
  1805. X.IP LOGDIR 8
  1806. XYour home directory if HOME is undefined.
  1807. X.SH FILES
  1808. X/usr/lib/news/active or a reasonable facsimile
  1809. X.br
  1810. X${DOTDIR-{$HOME-$LOGDIR}}/.newsrc
  1811. X.SH SEE ALSO
  1812. Xrn(1), newsrc(5)
  1813. X.SH DIAGNOSTICS
  1814. X.SH BUGS
  1815. XThe flag argument is a kludge.
  1816. END_OF_FILE
  1817.   if test 1706 -ne `wc -c <'newsgroups.1'`; then
  1818.     echo shar: \"'newsgroups.1'\" unpacked with wrong size!
  1819.   fi
  1820.   # end of 'newsgroups.1'
  1821. fi
  1822. if test -f 'newsgroups.SH' -a "${1}" != "-c" ; then 
  1823.   echo shar: Will not clobber existing file \"'newsgroups.SH'\"
  1824. else
  1825.   echo shar: Extracting \"'newsgroups.SH'\" \(2796 characters\)
  1826.   sed "s/^X//" >'newsgroups.SH' <<'END_OF_FILE'
  1827. Xcase $CONFIG in
  1828. X    '') . ./config.sh ;;
  1829. Xesac
  1830. Xecho "Extracting newsgroups (with variable substitutions)"
  1831. X$spitshell >newsgroups <<!GROK!THIS!
  1832. X$startsh
  1833. X# $Header: newsgroups.SH,v 4.3.3.1 91/01/16 03:18:14 davison Trn $
  1834. X# 
  1835. X# $Log:    newsgroups.SH,v $
  1836. X# Revision 4.3.3.1  91/01/16  03:18:14  davison
  1837. X# Integrated rn patches 48-54.
  1838. X# 
  1839. X# Revision 4.3.2.7  90/04/23  19:30:41  sob
  1840. X# Extra space removed to make second part of newsgroups work.
  1841. X# Sigh.
  1842. X# 
  1843. X# Revision 4.3.2.6  90/04/06  20:35:37  sob
  1844. X# Added fixes for SCO Xenix sent by ronald@robobar.co.uk.
  1845. X# 
  1846. X# Revision 4.3.2.5  90/03/17  17:27:00  sob
  1847. X# System V sed and BSD sed don't work quite alike. This change uses a
  1848. X# syntax that is common between them.
  1849. X# 
  1850. X# Revision 4.3.2.4  89/11/08  01:13:35  sob
  1851. X# Finished modifications to make work with RN and RRN
  1852. X# 
  1853. X# Revision 4.3.2.3  89/11/07  22:58:04  sob
  1854. X# Added final changes to allow rn and rrn to be built from same sources.
  1855. X# 
  1856. X# Revision 4.3.2.2  89/11/07  22:52:22  sob
  1857. X# Added prelimiary support to allow both rrn and rn to be built from same
  1858. X# sources.
  1859. X# 
  1860. X# Revision 4.3.2.1  89/11/06  01:04:39  sob
  1861. X# Added RRN support from NNTP 1.5
  1862. X# 
  1863. X# Revision 4.3  85/05/01  11:43:27  lwall
  1864. X# Baseline for release with 4.3bsd.
  1865. X# 
  1866. X
  1867. Xexport PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh \$0; kill \$\$)
  1868. X
  1869. X: syntax: newsgroups [pattern] [pipeflag]
  1870. X
  1871. X: System Dependencies
  1872. X
  1873. X: You might want to change pager to a "make column" program if you have one.
  1874. X: On the other hand, if your kernel does paging, cat would probably do.
  1875. Xpager="${pager-/usr/ucb/more}"
  1876. X#NORMALactive="${active-/usr/lib/news/active}"
  1877. X
  1878. X#NORMALcase \$active in
  1879. X#NORMAL~*) active=\`$filexp \$active\` ;;
  1880. X#NORMALesac
  1881. X
  1882. X#NNTPactive="/tmp/active.\$\$"
  1883. X
  1884. X: End of system dependencies, hopefully
  1885. X
  1886. X#NNTP$rnlib/getactive \$active
  1887. X
  1888. Xif $test \$# -ge 2 ; then
  1889. X    pager=$cat
  1890. Xelse
  1891. X    $echo "Completely unsubscribed newsgroups:"
  1892. Xfi
  1893. X
  1894. Xdotdir=\${DOTDIR-\${HOME-\$LOGDIR}}
  1895. X
  1896. X: Throwing .newsrc into the pot twice is a lovely hack to prevent
  1897. X: bogus newsgroups from showing up as unsubscribed.
  1898. X
  1899. X$cat \$dotdir/.newsrc \$dotdir/.newsrc \$active | \\
  1900. X$sed -n    -e '/^options/d' \\
  1901. X    -e '/^[     ]/d' \\
  1902. X    -e '/^control/d' \\
  1903. X    -e '/^to\./d' \\
  1904. X    -e 's/^\([^ !:]*\)[ !:].*\$/\1/' \\
  1905. X    -e "/.*\$1/p" | \\
  1906. X$sort | $uniq -u | \$pager
  1907. Xif $test \$# -ge 2 ; then
  1908. X    exit
  1909. Xfi
  1910. X$echo $n "[Type return to continue] $c"
  1911. Xread tmp
  1912. X$echo ""
  1913. X$echo "Unsubscribed but mentioned in .newsrc:"
  1914. X$sed -n < \$dotdir/.newsrc \\
  1915. X    -e "/\$1.*!/"'s/^\([^!]*\)!.*\$/\1/p' | \\
  1916. X$sort | \$pager
  1917. X!GROK!THIS!
  1918. Xcase "$isrrn" in
  1919. Xdefine)  sed < newsgroups -e '/^#NNTP/s/^#NNTP//' -e '/^#NORMAL/d' > newsgroups.new ;;
  1920. X*) sed < newsgroups -e '/^#NNTP/d' -e '/^#NORMAL/s/^#NORMAL//' > newsgroups.new ;;
  1921. Xesac
  1922. Xmv newsgroups.new newsgroups
  1923. X$eunicefix newsgroups
  1924. Xchmod 755 newsgroups
  1925. END_OF_FILE
  1926.   if test 2796 -ne `wc -c <'newsgroups.SH'`; then
  1927.     echo shar: \"'newsgroups.SH'\" unpacked with wrong size!
  1928.   fi
  1929.   chmod +x 'newsgroups.SH'
  1930.   # end of 'newsgroups.SH'
  1931. fi
  1932. if test -f 'ngsrch.c' -a "${1}" != "-c" ; then 
  1933.   echo shar: Will not clobber existing file \"'ngsrch.c'\"
  1934. else
  1935.   echo shar: Extracting \"'ngsrch.c'\" \(2770 characters\)
  1936.   sed "s/^X//" >'ngsrch.c' <<'END_OF_FILE'
  1937. X/* $Header: ngsrch.c,v 4.3 85/05/01 11:44:51 lwall Exp $
  1938. X *
  1939. X * $Log:    ngsrch.c,v $
  1940. X * Revision 4.3  85/05/01  11:44:51  lwall
  1941. X * Baseline for release with 4.3bsd.
  1942. X * 
  1943. X */
  1944. X
  1945. X#include "EXTERN.h"
  1946. X#include "common.h"
  1947. X#include "rcstuff.h"
  1948. X#include "final.h"
  1949. X#include "search.h"
  1950. X#include "rn.h"
  1951. X#include "util.h"
  1952. X#include "term.h"
  1953. X#include "rcln.h"
  1954. X#include "INTERN.h"
  1955. X#include "ngsrch.h"
  1956. X
  1957. X#ifdef NGSORONLY
  1958. X    COMPEX ngcompex;
  1959. X#endif
  1960. X
  1961. Xvoid
  1962. Xngsrch_init()
  1963. X{
  1964. X#ifdef ZEROGLOB
  1965. X    init_compex(&ngcompex);
  1966. X#endif    /* ZEROGLOB */
  1967. X    ;
  1968. X}
  1969. X
  1970. X#ifdef NGSEARCH
  1971. Xint
  1972. Xng_search(patbuf,get_cmd)
  1973. Xchar *patbuf;                /* if patbuf != buf, get_cmd must */
  1974. Xint get_cmd;                /*   be set to FALSE!!! */
  1975. X{
  1976. X    char *pattern;            /* unparsed pattern */
  1977. X    register char cmdchr = *patbuf;    /* what kind of search? */
  1978. X    register char *s;
  1979. X    bool backward = cmdchr == '?';    /* direction of search */
  1980. X
  1981. X    int_count = 0;
  1982. X    if (get_cmd && buf == patbuf)
  1983. X    if (!finish_command(FALSE))        /* get rest of command */
  1984. X        return NGS_ABORT;
  1985. X    for (pattern = patbuf+1; *pattern == ' '; pattern++) ;
  1986. X    if (*pattern) {
  1987. X    ng_doread = FALSE;
  1988. X    }
  1989. X    s = rindex(pattern,cmdchr);
  1990. X    if (s != Nullch && *(s-1) != '\\') {
  1991. X    *s++ = '\0';
  1992. X    if (index(s,'r') != Nullch)
  1993. X        ng_doread = TRUE;
  1994. X    }
  1995. X    if ((s = ng_comp(&ngcompex,pattern,TRUE,TRUE)) != Nullch) {
  1996. X                    /* compile regular expression */
  1997. X    printf("\n%s\n",s) FLUSH;
  1998. X    return NGS_ABORT;
  1999. X    }
  2000. X    fputs("\nSearching...",stdout) FLUSH;    /* give them something to read */
  2001. X    fflush(stdout);
  2002. X    for (;;) {
  2003. X    if (int_count) {
  2004. X        int_count = 0;
  2005. X        return NGS_INTR;
  2006. X    }
  2007. X    if (backward) {
  2008. X        if (ng > 0)
  2009. X        --ng;
  2010. X        else
  2011. X        ng = nextrcline;
  2012. X    }
  2013. X    else {
  2014. X        if (ng >= nextrcline)
  2015. X        ng = 0;
  2016. X        else
  2017. X        ++ng;
  2018. X    }
  2019. X    if (ng == current_ng)
  2020. X        return NGS_NOTFOUND;
  2021. X    if (ng == nextrcline || toread[ng] < TR_NONE || !ng_wanted())
  2022. X        continue;
  2023. X    if (toread[ng] == TR_NONE)
  2024. X        set_toread(ng);
  2025. X    
  2026. X    if (toread[ng] > TR_NONE)
  2027. X        return NGS_FOUND;
  2028. X    else if (toread[ng] == TR_NONE)
  2029. X        if (ng_doread)
  2030. X        return NGS_FOUND;
  2031. X        else
  2032. X        printf("\n[0 unread in %s--skipping]",rcline[ng]) FLUSH;
  2033. X    }
  2034. X}
  2035. X
  2036. Xbool
  2037. Xng_wanted()
  2038. X{
  2039. X    return execute(&ngcompex,rcline[ng]) != Nullch;
  2040. X}
  2041. X#endif
  2042. X
  2043. X#ifdef NGSORONLY
  2044. Xchar *
  2045. Xng_comp(compex,pattern,RE,fold)
  2046. XCOMPEX *compex;
  2047. Xchar *pattern;
  2048. Xbool RE;
  2049. Xbool fold;
  2050. X{
  2051. X    char ng_pattern[128];
  2052. X    register char *s = pattern, *d = ng_pattern;
  2053. X
  2054. X    if (!*s)
  2055. X    return Nullch;            /* reuse old pattern */
  2056. X    for (; *s; s++) {
  2057. X    if (*s == '.') {
  2058. X        *d++ = '\\';
  2059. X        *d++ = *s;
  2060. X    }
  2061. X    else if (*s == '?') {
  2062. X        *d++ = '.';
  2063. X    }
  2064. X    else if (*s == '*') {
  2065. X        *d++ = '.';
  2066. X        *d++ = *s;
  2067. X    }
  2068. X    else if (strnEQ(s,"all",3)) {
  2069. X        *d++ = '.';
  2070. X        *d++ = '*';
  2071. X        s += 2;
  2072. X    }
  2073. X    else
  2074. X        *d++ = *s;
  2075. X    }
  2076. X    *d = '\0';
  2077. X    return compile(compex,ng_pattern,RE,fold);
  2078. X}
  2079. X#endif
  2080. X
  2081. END_OF_FILE
  2082.   if test 2770 -ne `wc -c <'ngsrch.c'`; then
  2083.     echo shar: \"'ngsrch.c'\" unpacked with wrong size!
  2084.   fi
  2085.   # end of 'ngsrch.c'
  2086. fi
  2087. if test -f 'only.c' -a "${1}" != "-c" ; then 
  2088.   echo shar: Will not clobber existing file \"'only.c'\"
  2089. else
  2090.   echo shar: Extracting \"'only.c'\" \(2551 characters\)
  2091.   sed "s/^X//" >'only.c' <<'END_OF_FILE'
  2092. X/* $Header: only.c,v 4.3.3.2 91/01/16 03:26:16 davison Trn $
  2093. X *
  2094. X * $Log:    only.c,v $
  2095. X * Revision 4.3.3.2  91/01/16  03:26:16  davison
  2096. X * Integrated rn patches 48-54.
  2097. X * 
  2098. X * Revision 4.3.3.1  90/06/20  22:39:13  davison
  2099. X * Initial Trn Release
  2100. X * 
  2101. X * Revision 4.3.2.1  90/11/22  16:11:20  sob
  2102. X * Added changes to accomodate pickly C preprocessors.
  2103. X * 
  2104. X * Revision 4.3  85/05/01  11:45:21  lwall
  2105. X * Baseline for release with 4.3bsd.
  2106. X * 
  2107. X */
  2108. X
  2109. X#include "EXTERN.h"
  2110. X#include "common.h"
  2111. X#include "search.h"
  2112. X#include "util.h"
  2113. X#include "final.h"
  2114. X#include "ngsrch.h"
  2115. X#include "INTERN.h"
  2116. X#include "only.h"
  2117. X
  2118. Xvoid
  2119. Xonly_init()
  2120. X{
  2121. X    ;
  2122. X}
  2123. X
  2124. Xvoid
  2125. Xsetngtodo(pat)
  2126. Xchar *pat;
  2127. X{
  2128. X    char *s;
  2129. X
  2130. X#ifdef ONLY
  2131. X    if (!*pat)
  2132. X    return;
  2133. X    if (maxngtodo < NGMAX) {
  2134. X    ngtodo[maxngtodo] = savestr(pat);
  2135. X#ifdef SPEEDOVERMEM
  2136. X#ifndef lint
  2137. X    compextodo[maxngtodo] = (COMPEX*)safemalloc(sizeof(COMPEX));
  2138. X#endif /* lint */
  2139. X    init_compex(compextodo[maxngtodo]);
  2140. X    compile(compextodo[maxngtodo],pat,TRUE,TRUE);
  2141. X    if ((s = ng_comp(compextodo[maxngtodo],pat,TRUE,TRUE)) != Nullch) {
  2142. X                        /* compile regular expression */
  2143. X        printf("\n%s\n",s) FLUSH;
  2144. X        finalize(1);
  2145. X    }
  2146. X#endif
  2147. X    maxngtodo++;
  2148. X    }
  2149. X#else
  2150. X    notincl("o");
  2151. X#endif
  2152. X}
  2153. X
  2154. X/* if command line list is non-null, is this newsgroup wanted? */
  2155. X
  2156. Xbool
  2157. Xinlist(ngnam)
  2158. Xchar *ngnam;
  2159. X{
  2160. X#ifdef ONLY
  2161. X    register int i;
  2162. X#ifdef SPEEDOVERMEM
  2163. X
  2164. X    if (maxngtodo == 0)
  2165. X    return TRUE;
  2166. X    for (i=0; i<maxngtodo; i++) {
  2167. X    if (execute(compextodo[i],ngnam))
  2168. X        return TRUE;
  2169. X    }
  2170. X    return FALSE;
  2171. X#else
  2172. X    COMPEX ilcompex;
  2173. X    char *s;
  2174. X
  2175. X    if (maxngtodo == 0)
  2176. X    return TRUE;
  2177. X    init_compex(&ilcompex);
  2178. X    for (i=0; i<maxngtodo; i++) {
  2179. X    if ((s = ng_comp(&ilcompex,ngtodo[i],TRUE,TRUE)) != Nullch) {
  2180. X                        /* compile regular expression */
  2181. X        printf("\n%s\n",s) FLUSH;
  2182. X        finalize(1);
  2183. X    }
  2184. X    
  2185. X    if (execute(&ilcompex,ngnam) != Nullch) {
  2186. X        free_compex(&ilcompex);
  2187. X        return TRUE;
  2188. X    }
  2189. X    }
  2190. X    free_compex(&ilcompex);
  2191. X    return FALSE;
  2192. X#endif
  2193. X#else
  2194. X    return TRUE;
  2195. X#endif
  2196. X}
  2197. X
  2198. X#ifdef ONLY
  2199. Xvoid
  2200. Xend_only()
  2201. X{
  2202. X    if (maxngtodo) {            /* did they specify newsgroup(s) */
  2203. X    int whicharg;
  2204. X
  2205. X#ifdef VERBOSE
  2206. X    IF(verbose)
  2207. X        printf("\nRestriction %s%s removed.\n",ngtodo[0],
  2208. X        maxngtodo > 1 ? ", etc." : nullstr) FLUSH;
  2209. X    ELSE
  2210. X#endif
  2211. X#ifdef TERSE
  2212. X        fputs("\nExiting \"only\".\n",stdout) FLUSH;
  2213. X#endif
  2214. X    for (whicharg = 0; whicharg < maxngtodo; whicharg++) {
  2215. X        free(ngtodo[whicharg]);
  2216. X#ifdef SPEEDOVERMEM
  2217. X        free_compex(compextodo[whicharg]);
  2218. X#ifndef lint
  2219. X        free((char*)compextodo[whicharg]);
  2220. X#endif /* lint */
  2221. X#endif
  2222. X    }
  2223. X    maxngtodo = 0;
  2224. X    }
  2225. X}
  2226. X#endif
  2227. END_OF_FILE
  2228.   if test 2551 -ne `wc -c <'only.c'`; then
  2229.     echo shar: \"'only.c'\" unpacked with wrong size!
  2230.   fi
  2231.   # end of 'only.c'
  2232. fi
  2233. if test -f 'rthreads.h' -a "${1}" != "-c" ; then 
  2234.   echo shar: Will not clobber existing file \"'rthreads.h'\"
  2235. else
  2236.   echo shar: Extracting \"'rthreads.h'\" \(1674 characters\)
  2237.   sed "s/^X//" >'rthreads.h' <<'END_OF_FILE'
  2238. X/* $Header: rthreads.h,v 4.3.3.2 91/01/16 03:28:54 davison Trn $
  2239. X**
  2240. X** $Log:    rthreads.h,v $
  2241. X** Revision 4.3.3.2  91/01/16  03:28:54  davison
  2242. X** Added optional prototyping.
  2243. X** 
  2244. X** Revision 4.3.3.1  90/06/20  22:56:01  davison
  2245. X** Initial Trn Release
  2246. X** 
  2247. X*/
  2248. X
  2249. X#include "threads.h"
  2250. X
  2251. XEXT TOTAL total;
  2252. X
  2253. XEXT PACKED_ROOT *p_roots INIT(0);
  2254. XEXT WORD *root_subjects INIT(0);
  2255. XEXT WORD *author_cnts INIT(0);
  2256. XEXT WORD *subject_cnts INIT(0);
  2257. XEXT char **author_ptrs INIT(0);
  2258. XEXT char **subject_ptrs INIT(0);
  2259. XEXT PACKED_ARTICLE *p_articles INIT(0);
  2260. XEXT WORD *root_article_cnts INIT(0);
  2261. XEXT char *selected_roots INIT(0);
  2262. XEXT ART_NUM *saved_selections INIT(0);
  2263. XEXT bool unread_selector INIT(0);
  2264. X
  2265. XEXT PACKED_ARTICLE *p_art INIT(0);
  2266. XEXT PACKED_ARTICLE *curr_p_art INIT(0);
  2267. XEXT PACKED_ARTICLE *recent_p_art INIT(0);
  2268. X
  2269. XEXT int selected_root_cnt INIT(0);
  2270. XEXT ART_NUM selected_count INIT(0);
  2271. XEXT int unthreaded INIT(0);
  2272. XEXT int select_page;
  2273. XEXT bool scan_all_roots;
  2274. X
  2275. XEXT bool word_same, long_same;
  2276. XEXT BMAP my_bmap, mt_bmap;
  2277. X
  2278. Xvoid thread_init ANSI((void));
  2279. Xvoid mybytemap ANSI((BMAP *));
  2280. Xchar *thread_name ANSI((char *));
  2281. Xchar *safemalloc ANSI((MEM_SIZE));
  2282. Xint use_data ANSI((char *));
  2283. Xvoid unuse_data ANSI((bool));
  2284. Xvoid find_article ANSI((ART_NUM));
  2285. Xvoid init_tree ANSI((void));
  2286. Xvoid entire_tree ANSI((void));
  2287. Xint tree_puts ANSI((char *,ART_LINE,int));
  2288. Xint finish_tree ANSI((ART_LINE));
  2289. Xvoid first_art ANSI((void));
  2290. Xvoid follow_thread ANSI((char));
  2291. Xvoid next_root ANSI((void));
  2292. Xvoid prev_root ANSI((void));
  2293. Xchar select_thread ANSI((char));
  2294. Xint count_roots ANSI((bool));
  2295. Xint count_one_root ANSI((int));
  2296. XPACKED_ARTICLE *upper_limit ANSI((PACKED_ARTICLE *,bool));
  2297. X
  2298. X#define Nullart Null(PACKED_ARTICLE*)
  2299. END_OF_FILE
  2300.   if test 1674 -ne `wc -c <'rthreads.h'`; then
  2301.     echo shar: \"'rthreads.h'\" unpacked with wrong size!
  2302.   fi
  2303.   # end of 'rthreads.h'
  2304. fi
  2305. if test -f 'threads.c' -a "${1}" != "-c" ; then 
  2306.   echo shar: Will not clobber existing file \"'threads.c'\"
  2307. else
  2308.   echo shar: Extracting \"'threads.c'\" \(2230 characters\)
  2309.   sed "s/^X//" >'threads.c' <<'END_OF_FILE'
  2310. X/* $Header: threads.c,v 4.3.3.2 90/08/20 16:49:38 davison Trn $
  2311. X**
  2312. X** $Log:    threads.c,v $
  2313. X** Revision 4.3.3.2  90/08/20  16:49:38  davison
  2314. X** Enlarged path buffers to be more consistent.
  2315. X** 
  2316. X** Revision 4.3.3.1  90/07/21  20:33:23  davison
  2317. X** Initial Trn Release
  2318. X** 
  2319. X*/
  2320. X
  2321. X#include "EXTERN.h"
  2322. X#include "common.h"
  2323. X#include "threads.h"
  2324. X
  2325. X#ifdef USETHREADS
  2326. X
  2327. X/* Change a newsgroup name into the name of the thread data file.  We
  2328. X** subsitute any '.'s in the group name into '/'s (unless LONG_THREAD_NAMES
  2329. X** is defined), prepend the path, and append the '/.thread' (or '.th') on to
  2330. X** the end.
  2331. X*/
  2332. Xchar *
  2333. Xthread_name( group )
  2334. Xchar *group;
  2335. X{
  2336. X    register char *ptr;
  2337. X    static char name_buff[512];
  2338. X#ifndef LONG_THREAD_NAMES
  2339. X    char group_buff[512];
  2340. X
  2341. X    strcpy( group_buff, group);
  2342. X    ptr = group = group_buff;
  2343. X    while( (ptr = index( ptr, '.' )) ) {
  2344. X    *ptr = '/';
  2345. X    }
  2346. X#endif
  2347. X#ifdef SUFFIX
  2348. X    sprintf( name_buff, "%s/%s%s", THREAD_DIR, group, SUFFIX );
  2349. X#else
  2350. X    sprintf( name_buff, "%s/%s", THREAD_DIR, group );
  2351. X#endif
  2352. X
  2353. X    return name_buff;
  2354. X}
  2355. X
  2356. X/* Determine this machine's byte map for WORDs and LONGs.  A byte map is an
  2357. X** array of BYTEs (sizeof (WORD) or sizeof (LONG) of them) with the 0th BYTE
  2358. X** being the byte number of the high-order byte in my <type>, and so forth.
  2359. X*/
  2360. Xvoid
  2361. Xmybytemap( map )
  2362. XBMAP *map;
  2363. X{
  2364. X    union {
  2365. X    BYTE b[sizeof (LONG)];
  2366. X    WORD w;
  2367. X    LONG l;
  2368. X    } u;
  2369. X    register BYTE *mp;
  2370. X    register int i, j;
  2371. X
  2372. X    mp = &map->w[sizeof (WORD)];
  2373. X    u.w = 1;
  2374. X    for( i = sizeof (WORD); i > 0; i-- ) {
  2375. X    for( j = 0; j < sizeof (WORD); j++ ) {
  2376. X        if( u.b[j] != 0 ) {
  2377. X        break;
  2378. X        }
  2379. X    }
  2380. X    if( j == sizeof (WORD) ) {
  2381. X        goto bad_news;
  2382. X    }
  2383. X    *--mp = j;
  2384. X    while( u.b[j] != 0 && u.w ) {
  2385. X        u.w <<= 1;
  2386. X    }
  2387. X    }
  2388. X
  2389. X    mp = &map->l[sizeof (LONG)];
  2390. X    u.l = 1;
  2391. X    for( i = sizeof (LONG); i > 0; i-- ) {
  2392. X    for( j = 0; j < sizeof (LONG); j++ ) {
  2393. X        if( u.b[j] != 0 ) {
  2394. X        break;
  2395. X        }
  2396. X    }
  2397. X    if( j == sizeof (LONG) ) {
  2398. X      bad_news:
  2399. X        /* trouble -- set both to *something* consistent */
  2400. X        for( j = 0; j < sizeof (WORD); j++ ) {
  2401. X        map->w[j] = j;
  2402. X        }
  2403. X        for( j = 0; j < sizeof (LONG); j++ ) {
  2404. X        map->l[j] = j;
  2405. X        }
  2406. X        return;
  2407. X    }
  2408. X    *--mp = j;
  2409. X    while( u.b[j] != 0 && u.l ) {
  2410. X        u.l <<= 1;
  2411. X    }
  2412. X    }
  2413. X}
  2414. X
  2415. X#endif /* USETHREADS */
  2416. END_OF_FILE
  2417.   if test 2230 -ne `wc -c <'threads.c'`; then
  2418.     echo shar: \"'threads.c'\" unpacked with wrong size!
  2419.   fi
  2420.   # end of 'threads.c'
  2421. fi
  2422. if test -f 'threads.h' -a "${1}" != "-c" ; then 
  2423.   echo shar: Will not clobber existing file \"'threads.h'\"
  2424. else
  2425.   echo shar: Extracting \"'threads.h'\" \(1989 characters\)
  2426.   sed "s/^X//" >'threads.h' <<'END_OF_FILE'
  2427. X/* $Header: threads.h,v 4.3.3.2 90/08/20 16:50:09 davison Trn $
  2428. X**
  2429. X** $Log:    threads.h,v $
  2430. X** Revision 4.3.3.2  90/08/20  16:50:09  davison
  2431. X** Padded odd-boundaried arrays.  Upgraded database version #.
  2432. X** 
  2433. X** Revision 4.3.3.1  90/06/20  22:56:18  davison
  2434. X** Initial Trn Release
  2435. X** 
  2436. X*/
  2437. X
  2438. X#define DB_VERSION    2
  2439. X
  2440. Xtypedef char        BYTE;
  2441. Xtypedef short        WORD;
  2442. Xtypedef long        LONG;
  2443. X
  2444. X#define ROOT_ARTICLE    0x0001        /* article flag definitions */
  2445. X#define NEW_ARTICLE    0x0002        /* to avoid stat'ing new articles */
  2446. X
  2447. Xtypedef struct Article {
  2448. X    ART_NUM num;
  2449. X    char *id;
  2450. X    struct Domain *domain;
  2451. X    struct Subject *subject;
  2452. X    struct Author *author;
  2453. X    struct Article *parent, *children, *siblings;
  2454. X    struct Root *root;
  2455. X    struct Article *id_link;
  2456. X    time_t date;
  2457. X    WORD child_cnt;
  2458. X    WORD flags;
  2459. X    WORD seq;
  2460. X} ARTICLE;
  2461. X
  2462. Xtypedef struct Domain {
  2463. X    char *name;
  2464. X    ARTICLE *ids;
  2465. X    struct Domain *link;
  2466. X} DOMAIN;
  2467. X
  2468. Xtypedef struct Author {
  2469. X    struct Author *link;        /* this link MUST be first */
  2470. X    char *name;
  2471. X    WORD seq;
  2472. X    WORD count;
  2473. X} AUTHOR;
  2474. X
  2475. Xtypedef struct Subject {
  2476. X    struct Subject *link;
  2477. X    char *str;
  2478. X    WORD seq;
  2479. X    WORD count;
  2480. X} SUBJECT;
  2481. X
  2482. Xtypedef struct Root {
  2483. X    struct Root *link;            /* this link MUST be first */
  2484. X    ARTICLE *articles;
  2485. X    SUBJECT *subjects;
  2486. X    ART_NUM root_num;
  2487. X    WORD thread_cnt;
  2488. X    WORD subject_cnt;
  2489. X    WORD seq;
  2490. X} ROOT;
  2491. X
  2492. Xtypedef struct {
  2493. X    LONG root_num;
  2494. X    WORD articles;
  2495. X    WORD thread_cnt;
  2496. X    WORD subject_cnt;
  2497. X    WORD pad_hack;
  2498. X} PACKED_ROOT;
  2499. X
  2500. Xtypedef struct {
  2501. X    LONG num;
  2502. X    LONG date;
  2503. X    WORD subject, author;
  2504. X    WORD flags;
  2505. X    WORD child_cnt;
  2506. X    WORD parent, children, siblings;
  2507. X    WORD root;
  2508. X} PACKED_ARTICLE;
  2509. X
  2510. Xtypedef struct Total {
  2511. X    LONG first, last;
  2512. X    LONG string1;
  2513. X    LONG string2;
  2514. X    WORD root;
  2515. X    WORD article;
  2516. X    WORD subject;
  2517. X    WORD author;
  2518. X    WORD domain;
  2519. X    WORD pad_hack;
  2520. X} TOTAL;
  2521. X
  2522. Xtypedef struct {
  2523. X    BYTE l[sizeof (LONG)];
  2524. X    BYTE w[sizeof (WORD)];
  2525. X    BYTE version;
  2526. X    BYTE pad_hack;
  2527. X} BMAP;
  2528. END_OF_FILE
  2529.   if test 1989 -ne `wc -c <'threads.h'`; then
  2530.     echo shar: \"'threads.h'\" unpacked with wrong size!
  2531.   fi
  2532.   # end of 'threads.h'
  2533. fi
  2534. echo shar: End of archive 13 \(of 14\).
  2535. cp /dev/null ark13isdone
  2536. MISSING=""
  2537. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
  2538.     if test ! -f ark${I}isdone ; then
  2539.     MISSING="${MISSING} ${I}"
  2540.     fi
  2541. done
  2542. if test "${MISSING}" = "" ; then
  2543.     echo You have unpacked all 14 archives.
  2544.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2545. else
  2546.     echo You still must unpack the following archives:
  2547.     echo "        " ${MISSING}
  2548. fi
  2549. exit 0
  2550.